|
@@ -1,23 +1,68 @@
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
import os
|
|
|
-from xml.etree import ElementTree as ET
|
|
|
+import shutil
|
|
|
+from xml.etree import ElementTree
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+top_root = "../result2/"
|
|
|
+
|
|
|
+
|
|
|
+FileSystemXML = "../FileSystem.xml"
|
|
|
|
|
|
-doc = ET.parse("template.xml").getroot()
|
|
|
+
|
|
|
+ContentFolder = "../Content"
|
|
|
+
|
|
|
+
|
|
|
+DryRun = True
|
|
|
|
|
|
|
|
|
def folder_walk(folder, indent, root):
|
|
|
indent += "\t"
|
|
|
- for folder_un in folder.findall('folder'):
|
|
|
- print indent + u"⊢ " + folder_un.get('name')
|
|
|
- folderpath = os.path.join(root, folder_un.get('name'))
|
|
|
- os.mkdir(folderpath)
|
|
|
+ for folder_un in folder.findall('Folder'):
|
|
|
+ print indent + u"⊢ " + folder_un.get('Name')
|
|
|
+ folderpath = os.path.join(root, folder_un.get('Name'))
|
|
|
+ if DryRun:
|
|
|
+ print indent + " make dir " + folderpath
|
|
|
+ else:
|
|
|
+ os.mkdir(folderpath)
|
|
|
folder_walk(folder_un, indent, folderpath)
|
|
|
- for file_elmt in folder.findall('file'):
|
|
|
- print indent + u"⊢ " + file_elmt.get('name') + " - " + file_elmt.get('data')
|
|
|
+ for file_elmt in folder.findall('File'):
|
|
|
+ if file_elmt.get('Content-Id') is not None:
|
|
|
+ print indent + u"⊢ " + file_elmt.get('Name') + " - " + file_elmt.get('Content-Id')
|
|
|
+ if DryRun:
|
|
|
+ print indent + " move " + os.path.join(ContentFolder, file_elmt.get('Content-Id')) + " to " + os.path.join(root, file_elmt.get('Name'))
|
|
|
+ else:
|
|
|
+ shutil.move(os.path.join(ContentFolder, file_elmt.get('Content-Id')), os.path.join(root, file_elmt.get('Name')))
|
|
|
+
|
|
|
+
|
|
|
+doc = ElementTree.parse(FileSystemXML).getroot()
|
|
|
|
|
|
+if DryRun:
|
|
|
+ print "make dir " + top_root
|
|
|
+else:
|
|
|
+ os.mkdir(top_root)
|
|
|
|
|
|
-for content in doc.findall('content'):
|
|
|
+for content in doc.findall('Volume')[0].findall('Content'):
|
|
|
print content.tag
|
|
|
- folder_walk(content, " ", "./")
|
|
|
+ folder_walk(content, " ", top_root)
|
|
|
|