Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def loadValues():
path = inputPath / 'values.qface'
return FileSystem.parse_document(path)
def loadEcho():
path = inputPath / 'org.example.echo.qface'
return FileSystem.parse_document(path)
def loadTuner():
path = inputPath / 'com.pelagicore.ivi.tuner.qface'
return FileSystem.parse_document(path)
def test_destination_prefix():
system = FileSystem.parse(inputPath)
out = Path('tests/out')
out.rmtree_p()
out.makedirs_p()
generator = Generator(search_path='tests/templates')
for module in system.modules:
dst_template = '{{out}}/{{module|lower}}.txt'
ctx = {'out': out.abspath(), 'module': module}
generator.write(dst_template, 'module.txt', ctx)
path = generator.apply(dst_template, ctx)
assert Path(path).exists()
out.rmtree_p()
def generate(tplconfig, moduleConfig, annotations, src, dst):
log.debug('run {0} {1}'.format(src, dst))
FileSystem.strict = True
Generator.strict = True
system = FileSystem.parse(src)
for annotations_file in annotations:
log.debug('{0}'.format(annotations_file))
if not os.path.isabs(annotations_file):
annotations_file = Path.getcwd() / str(annotations_file)
if not Path(annotations_file).exists():
print('no such annotation file: {0}'.format(annotations_file))
exit(1)
FileSystem.merge_annotations(system, Path(annotations_file))
generator = Generator(search_path=[tplconfig, here])
generator.env.keep_trailing_newline = True
generator.register_filter('return_type', return_type)
generator.register_filter('parameter_type_default', parameter_type_default)
generator.register_filter('parameter_type', parameter_type)
def parse_document(document: Path, system: System = None, profile=EProfile.FULL):
error = False
try:
return FileSystem._parse_document(document, system, profile)
except FileNotFoundError as e:
click.secho('{0}: error: file not found'.format(document), fg='red', err=True)
error = True
except ValueError as e:
click.secho('Error parsing document {0}'.format(document), fg='red', err=True)
error = True
if error and FileSystem.strict:
sys.exit(-1)
cache = None
if use_cache:
cache = shelve.open('qface.cache')
if identifier in cache and clear_cache:
del cache[identifier]
if identifier in cache:
# use the cached domain model
system = cache[identifier]
# if domain model not cached generate it
for input in inputs:
path = Path.getcwd() / str(input)
if path.isfile():
FileSystem.parse_document(path, system)
else:
for document in path.walkfiles(pattern):
FileSystem.parse_document(document, system)
if use_cache:
cache[identifier] = system
return system