Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(config_filename):
if not isfile(config_filename):
click.echo(f'Could not find configuration file {config_filename}')
config = Config.load(config_filename)
schema = load_schema(config.schema)
filenames = glob.glob(config.documents, recursive=True)
query_parser = QueryParser(schema)
query_renderer = DataclassesRenderer(schema, config)
for filename in filenames:
process_file(filename, query_parser, query_renderer)
def get_schema():
if 'SCHEMA' not in globals():
config = get_config()
globals()['SCHEMA'] = load_schema(config.schema)
return globals()['SCHEMA']
if event.is_directory:
return
if event.event_type in {EVENT_TYPE_CREATED, EVENT_TYPE_MODIFIED}:
filenames = [os.path.abspath(fn) for fn in glob.iglob(config.documents, recursive=True)]
if event.src_path not in filenames:
return
# Take any action here when a file is first created.
process_file(event.src_path, self.parser, self.renderer)
if not isfile(config_filename):
click.echo(f'Could not find configuration file {config_filename}')
config = Config.load(config_filename)
schema = load_schema(config.schema)
click.secho(f'Watching {config.documents}', fg='cyan')
click.secho('Ready for changes...', fg='cyan')
observer = Observer()
observer.schedule(Handler(config, schema), os.path.abspath('./'), recursive=True)
observer.start()
try:
while True:
time.sleep(5)
except:
observer.stop()
print('Error')
observer.join()