forked from lardissone/FlashFXP-To-Filezilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.py
More file actions
82 lines (66 loc) · 3.09 KB
/
convert.py
File metadata and controls
82 lines (66 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
import os
from xml.dom import minidom
import sys
def main():
flash_file = sys.argv[1]
xml_file = os.path.abspath(__file__)
xml_file = os.path.dirname(xml_file)
xml_file = os.path.join(xml_file, flash_file)
try:
xmldoc = minidom.parse(xml_file)
except Exception, inst:
print "No, no :("
print "-Please, be sure that this file exists: %s" % xml_file
print inst
return
nodes = xmldoc.getElementsByTagName('SITE')
xml_str = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><FileZilla3><Servers>'
xml_str += '<Folder expanded="1">Imported from FlashFXP
 '
for node in nodes:
name = node.attributes['NAME'].value
group = node.getElementsByTagName('GROUP')[0].firstChild.data[1:-1] \
if node.getElementsByTagName('GROUP') else ''
folders = group.split('\\');
for folder in folders:
xml_str += '<Folder>'+folder+'
 \n'
server = node.getElementsByTagName('ADDRESS')[0].firstChild.data \
if node.getElementsByTagName('ADDRESS') else ''
port = node.getElementsByTagName('PORT')[0].firstChild.data \
if node.getElementsByTagName('PORT') else 21
user = node.getElementsByTagName('USERNAME')[0].firstChild.data \
if node.getElementsByTagName('USERNAME') else ''
passw = node.getElementsByTagName('PASSWORD')[0].firstChild.data \
if node.getElementsByTagName('PASSWORD') else ''
localpath = node.getElementsByTagName('LOCALPATH')[0].firstChild.data \
if node.getElementsByTagName('LOCALPATH') else ''
remotepath = node.getElementsByTagName('REMOTEPATH')[0].firstChild.data \
if node.getElementsByTagName('REMOTEPATH') else ''
xml_str += '<Server>\n'
xml_str += '<Host>' + str(server) + '</Host>'
xml_str += '<Port>' + str(port) + '</Port>'
xml_str += '<Protocol>0</Protocol>'
xml_str += '<Type>0</Type>'
xml_str += '<User>' + str(user) + '</User>'
xml_str += '<Pass>' + str(passw) + '</Pass>'
xml_str += '<Logontype>1</Logontype>'
xml_str += '<TimezoneOffset>0</TimezoneOffset>'
xml_str += '<PasvMode>MODE_DEFAULT</PasvMode>'
xml_str += '<MaximumMultipleConnections>0</MaximumMultipleConnections>'
xml_str += '<EncodingType>Auto</EncodingType>'
xml_str += '<BypassProxy>0</BypassProxy>'
xml_str += '<Name>' + str(name) + '</Name>'
xml_str += '<Comments>Imported from FlashFXP</Comments>'
xml_str += '<LocalDir>' + str(localpath) + '</LocalDir>'
xml_str += '<RemoteDir>' + str(remotepath) + '</RemoteDir>'
xml_str += '<SyncBrowsing>0</SyncBrowsing>'+ str(name) +'
 '
xml_str += '</Server>\n'
for folder in folders:
xml_str += '</Folder>\n'
xml_str += '</Folder>'
xml_str += '</Servers></FileZilla3>'
xml_output_file = open('FileZilla.xml', 'w')
xml_output_file.write(xml_str)
xml_output_file.close()
if __name__ == "__main__":
main()