mirror of
https://github.com/phodina/ProjectConverter.git
synced 2026-04-30 19:09:16 +08:00
Added code to find the project file in the directory.
This commit is contained in:
parent
7b24babefb
commit
71f1ae6347
48
converter.py
48
converter.py
@ -1,6 +1,52 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import argparse
|
||||
import ewpproject
|
||||
import uvprojxproject
|
||||
|
||||
def findFile (path,fileext):
|
||||
|
||||
file = ''
|
||||
for root, dirs, files in os.walk(path):
|
||||
for file in files:
|
||||
if file.endswith(fileext):
|
||||
file = os.path.join(root, file)
|
||||
|
||||
return file
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
pass
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("path", type=str, help="Root directory of project")
|
||||
parser.add_argument("--ewp",help="Search for *.EWP file in project structure",action='store_true')
|
||||
parser.add_argument("--uvprojx",help="Search for *.UPROJX file in project structure",action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if (os.path.isdir (args.path)):
|
||||
|
||||
if args.ewp:
|
||||
print ('Looking for *.ewp file in ' + args.path)
|
||||
file = findFile(args.path,'.ewp')
|
||||
if (len(file)):
|
||||
print ('Found project file: ' + file)
|
||||
project = ewpproject.EWPProject(file)
|
||||
project.parseProject()
|
||||
project.displaySummary()
|
||||
else:
|
||||
print ('No project *.ewp file found')
|
||||
|
||||
elif args.uvprojx:
|
||||
print ('Looking for *.uvprojx file in ' + args.path)
|
||||
file = findFile(args.path,'.uvprojx')
|
||||
if (len(file)):
|
||||
print ('Found project file: ' + file)
|
||||
project = uvprojxproject.UVPROJXProject(file)
|
||||
project.parseProject()
|
||||
project.displaySummary()
|
||||
else:
|
||||
print ('No project *.uvprojx file found')
|
||||
else:
|
||||
|
||||
print ('Not a valid file path')
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import xmltree
|
||||
|
||||
from lxml import objectify
|
||||
|
||||
class EWPProject (object):
|
||||
@ -7,7 +7,7 @@ class EWPProject (object):
|
||||
def __init__(self, xmlFile):
|
||||
|
||||
self.xmlFile = xmlFile
|
||||
self.xmltree = objectify.parse(xmlFile)
|
||||
xmltree = objectify.parse(xmlFile)
|
||||
self.root = xmltree.getroot()
|
||||
|
||||
def parseProject(self):
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import xmltree
|
||||
from lxml import objectify
|
||||
|
||||
class UVPROJXProject (object):
|
||||
@ -7,7 +6,7 @@ class UVPROJXProject (object):
|
||||
def __init__(self, xmlFile):
|
||||
|
||||
self.xmlFile = xmlFile
|
||||
self.xmltree = objectify.parse(xmlFile)
|
||||
xmltree = objectify.parse(xmlFile)
|
||||
self.root = xmltree.getroot()
|
||||
|
||||
def parseProject (self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user