developer import from sourceforge
This commit is contained in:
@ -260,6 +260,35 @@ def read_entries():
|
||||
return entries
|
||||
|
||||
|
||||
def read_entry(file):
|
||||
"""
|
||||
Reads a single entry
|
||||
:param file: the entry file (without path)
|
||||
:return: the entry
|
||||
"""
|
||||
|
||||
# setup parser and transformer
|
||||
grammar_file = os.path.join(c.code_path, 'grammar_entries.lark')
|
||||
grammar = utils.read_text(grammar_file)
|
||||
parse = osg_parse.create(grammar, osg_parse.EntryTransformer)
|
||||
|
||||
# read entry file
|
||||
content = utils.read_text(os.path.join(c.entries_path, file))
|
||||
if not content.endswith('\n'):
|
||||
content += '\n'
|
||||
|
||||
# parse and transform entry content
|
||||
try:
|
||||
entry = parse(content)
|
||||
entry = [('File', file),] + entry # add file information to the beginning
|
||||
entry = check_and_process_entry(entry)
|
||||
except Exception as e:
|
||||
print('{} - {}'.format(file, e))
|
||||
raise RuntimeError(e)
|
||||
|
||||
return entry
|
||||
|
||||
|
||||
def check_and_process_entry(entry):
|
||||
message = ''
|
||||
|
||||
|
@ -21,11 +21,11 @@ class ListingTransformer(lark.Transformer):
|
||||
|
||||
def property(self, x):
|
||||
"""
|
||||
The key of a property will be converted to lower case and the value part is the second part
|
||||
Key is first part, values are following.
|
||||
:param x:
|
||||
:return:
|
||||
"""
|
||||
return x[0], x[1:]
|
||||
return x[0].value, x[1:]
|
||||
|
||||
def name(self, x):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user