First attempt at project rewrite
This commit is contained in:
parent
22f3308c4e
commit
dd1ab8018f
1 changed files with 30 additions and 1 deletions
|
@ -5,6 +5,7 @@ import re
|
|||
import io
|
||||
import glob
|
||||
import configparser
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
|
||||
def select_item(welcome_text, items):
|
||||
|
@ -25,11 +26,15 @@ def select_item(welcome_text, items):
|
|||
print('Error! Please enter one number between 1-{}'.format(len(items)))
|
||||
exit()
|
||||
|
||||
def get_filter(path):
|
||||
return "filter"
|
||||
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(os.path.join(sys.path[0],"config.ini"))
|
||||
rainbow = config["Options"]["rainbow_exec"]
|
||||
|
||||
work_directory = sys.argv[1:]
|
||||
|
||||
list_projects = os.listdir(os.path.join(sys.path[0],"projects"))
|
||||
project_folder = os.path.join(sys.path[0],"projects",select_item("Available projects:",list_projects))
|
||||
|
@ -38,4 +43,28 @@ project = os.path.join(project_folder,"project.rnb")
|
|||
list_pipelines = [os.path.basename(x) for x in glob.glob(os.path.join(sys.path[0],"projects",project_folder,"*.pln"))]
|
||||
pipeline = os.path.join(project_folder,select_item("Available pipelines:",list_pipelines))
|
||||
|
||||
subprocess.run([rainbow,"-p",project,"-pln",pipeline,"-np"])
|
||||
project_config = configparser.ConfigParser()
|
||||
project_config.read(os.path.join(project_folder,"project.ini"))
|
||||
|
||||
files = []
|
||||
|
||||
for directory in work_directory:
|
||||
if any(Path(directory).rglob('*.*')):
|
||||
for translationfile in Path(directory).rglob('*.*'):
|
||||
filter = get_filter(translationfile)
|
||||
if (filter != ""):
|
||||
files.append((translationfile,filter))
|
||||
|
||||
|
||||
project_tree = ET.parse(project)
|
||||
root = project_tree.getroot()
|
||||
|
||||
elem = root.find("./fileSet[@id='1']")
|
||||
for item in files:
|
||||
new=ET.Element("fi",attrib={"fs":item[1]})
|
||||
new.text=str(item[0])
|
||||
elem.append(new)
|
||||
|
||||
project_tree.write("testproject.rnb",encoding="UTF-8",xml_declaration=True)
|
||||
|
||||
#subprocess.run([rainbow,"-p",project,"-pln",pipeline,"-np"])
|
||||
|
|
Loading…
Add table
Reference in a new issue