Skip to content

Commit

Permalink
english location, fix the bugs in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
radeknovotny94 committed Jul 1, 2018
1 parent 04673f4 commit 0d9fc2f
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions GRASSDescribtionParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
reload(sys)
sys.setdefaultencoding('utf8')

# os.environ['LC_ALL'] = 'C'

def findGRASS():
"""Find GRASS.
Expand Down Expand Up @@ -67,6 +69,8 @@ def findGRASS():

# Set GISBASE environment variable
os.environ['GISBASE'] = gisbase
# set language to english
os.environ['LC_ALL'] = 'C'
# define GRASS-Python environment
sys.path.append(os.path.join(gisbase, "etc", "python"))

Expand Down Expand Up @@ -247,9 +251,13 @@ def check_tag(tag, branch):

for child in root:
if child.tag == 'label':
print(child.text.strip(), end=' ', file=desc_file)
label = child.text.strip()
label = label.replace('-', '')
print(label, end=' ', file=desc_file)
if child.tag == 'description':
print(child.text.strip(), end=' ', file=desc_file)
desc = child.text.strip()
desc = desc.replace('-', '')
print(desc, end=' ', file=desc_file)
print('', file=desc_file)
if name[:2] == 'r.':
print('Raster (r.*)', file=desc_file)
Expand Down Expand Up @@ -287,11 +295,22 @@ def check_tag(tag, branch):
else:
pass
if child.attrib['type'] == 'integer':
optional(child, desc_file)
print('QgsProcessingParameterNumber|', end='', file=desc_file)
print_name_desc(child, desc_file)
print('QgsProcessingParameterNumber.Integer|', end='', file=desc_file)
print_def_opt(child, desc_file)
if check_default(child):
for k in child:
if k.tag == 'default':
if ',' not in k.text.strip():
optional(child, desc_file)
print('QgsProcessingParameterNumber|', end='', file=desc_file)
print_name_desc(child, desc_file)
print('QgsProcessingParameterNumber.Integer|', end='', file=desc_file)
print_def_opt(child, desc_file)

else:
optional(child, desc_file)
print('QgsProcessingParameterRange|', end='', file=desc_file)
print_name_desc(child, desc_file)
print('QgsProcessingParameterNumber.Integer|', end='', file=desc_file)
print_def_opt(child, desc_file)

elif child.attrib['type'] == 'float':
optional(child, desc_file)
Expand Down Expand Up @@ -332,13 +351,13 @@ def check_tag(tag, branch):
print('QgsProcessingParameterMultipleLayers|', end='', file=desc_file)
print_name_desc(child, desc_file)
if k.attrib['prompt'] == 'raster':
print('TypeRaster|', end='', file=desc_file)
print('3|', end='', file=desc_file)
print_def_opt(child, desc_file)
elif k.attrib['prompt'] == 'vector':
print('TypeVector|', end='', file=desc_file)
print('2|', end='', file=desc_file)
print_def_opt(child, desc_file)
else:
print('TypeMapLayer|', end='', file=desc_file)
print('33|', end='', file=desc_file)
print_def_opt(child, desc_file)
else:
optional(child, desc_file)
Expand Down Expand Up @@ -373,13 +392,13 @@ def check_tag(tag, branch):
or child.attrib['name'] == 'signature':
optional(child, desc_file)
print('QgsProcessingParameterFile|', end='', file=desc_file)
print_name_def(child, desc_file)
print_name_desc(child, desc_file)
print('QgsProcessingParameterFile.File|txt|', end='', file=desc_file)
print_def_opt(child, desc_file)
elif k.attrib['prompt'] == 'datasource':
optional(child, desc_file)
print('QgsProcessingParameterFolder|', end='', file=desc_file)
print_name_def(child, desc_file)
print_name_desc(child, desc_file)
print('QgsProcessingParameterFile.Folder|None|', end='', file=desc_file)
print_def_opt(child, desc_file)
elif k.attrib['prompt'] == 'group' and child.attrib['name'] != 'subgroup':
Expand All @@ -393,10 +412,10 @@ def check_tag(tag, branch):
print('Input rasters|3|', end='', file=desc_file)
print_def_opt(child, desc_file)
elif name[:2] == 'v.':
print('Input vectors|TypeVector|', end='', file=desc_file)
print('Input vectors|2|', end='', file=desc_file)
print_def_opt(child, desc_file)
else:
print('Input layers|TypeMapLayer|', end='', file=desc_file)
print('Input layers|3|', end='', file=desc_file)
print_def_opt(child, desc_file)
elif k.attrib['prompt'] == 'separator' or k.attrib['prompt'] == 'color' \
or k.attrib['prompt'] == 'cats' or k.attrib['prompt'] == 'dbname' \
Expand Down

0 comments on commit 0d9fc2f

Please sign in to comment.