Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_things(ckan, thing, arguments,
worker_pool=None, stdin=None, stdout=None, stderr=None):
"""
create and update datasets, groups, orgs and users
The parent process creates a pool of worker processes and hands
out json lines to each worker as they finish a task. Status of
last record completed and records being processed is displayed
on stderr.
"""
if worker_pool is None:
worker_pool = workers.worker_pool
if stdin is None:
stdin = getattr(sys.stdin, 'buffer', sys.stdin)
if stdout is None:
stdout = getattr(sys.__stdout__, 'buffer', sys.__stdout__)
if stderr is None:
stderr = getattr(sys.stderr, 'buffer', sys.stderr)
if arguments['--worker']:
return load_things_worker(ckan, thing, arguments)
log = None
if arguments['--log']:
log = open(arguments['--log'], 'a')
jsonl_input = stdin
if arguments['--input']:
def dump_things(ckan, thing, arguments,
worker_pool=None, stdout=None, stderr=None):
"""
dump all datasets, groups, orgs or users accessible by the connected user
The parent process creates a pool of worker processes and hands
out ids to each worker. Status of last record completed and records
being processed is displayed on stderr.
"""
if worker_pool is None:
worker_pool = workers.worker_pool
if stdout is None:
stdout = getattr(sys.__stdout__, 'buffer', sys.__stdout__)
if stderr is None:
stderr = getattr(sys.stderr, 'buffer', sys.stderr)
if arguments['--worker']:
return dump_things_worker(ckan, thing, arguments)
log = None
if arguments['--log']:
log = open(arguments['--log'], 'a')
jsonl_output = stdout
if arguments['--datapackages']: # TODO: do we want to just divert this to devnull?
jsonl_output = open(os.devnull, 'wb')
if arguments['--output']:
def delete_things(ckan, thing, arguments,
worker_pool=None, stdin=None, stdout=None, stderr=None):
"""
delete datasets, groups, orgs, users etc,
The parent process creates a pool of worker processes and hands
out json lines to each worker as they finish a task. Status of
last record completed and records being processed is displayed
on stderr.
"""
if worker_pool is None:
worker_pool = workers.worker_pool
if stdin is None:
stdin = getattr(sys.stdin, 'buffer', sys.stdin)
if stdout is None:
stdout = getattr(sys.__stdout__, 'buffer', sys.__stdout__)
if stderr is None:
stderr = getattr(sys.stderr, 'buffer', sys.stderr)
if arguments['--worker']:
return delete_things_worker(ckan, thing, arguments)
log = None
if arguments['--log']:
log = open(arguments['--log'], 'a')
jsonl_input = stdin
if arguments['--input']: