def command(self): super(CKANImportCommand, self).command() self._check_args_length(1) package = ckan.Package(self.args[0]) if not self.options.use_ckan_tags: if not self.options.mapping: print("You must specify metadata mapping URL (--mapping)!", file=sys.stderr) return 1 if not self.options.resource: print("You must specify the resource UUID (--resource)!", file=sys.stderr) return 1 if self.options.use_ckan_tags: importer = CKANImporter(package) else: importer = CKANImporter(package, self.options.mapping, self.options.resource) try: importer.run(**self.get_args()) return 0 except ImporterError as e: log.error(e) return 1
def ckan_import(package_name, **kwargs): from openspending.etl.importer import CKANImporter importer = CKANImporter(package_name) importer.on_error = lambda e: log.warn(e) importer.run(**kwargs)
def first_error(package): importer = CKANImporter(package) try: importer.run(**kwargs) # If we reach the next line, no errors have been thrown, as # max_errors is set to 1. return "No errors" except ImporterError as e: return e
def ckan_import(package_name, **kwargs): from openspending.etl.importer import CKANImporter importer = CKANImporter(package_name) importer.on_error = lambda e: log.warn(e) opts = { 'max_errors': 500 } opts.update(kwargs) importer.run(**opts)
def ckanimport(package_name, args): package = ckan.Package(package_name) if not args.use_ckan_tags: if not args.mapping: print("You must specify metadata mapping URL (--mapping)!", file=sys.stderr) return 1 if not args.resource: print("You must specify the resource UUID (--resource)!", file=sys.stderr) return 1 if args.use_ckan_tags: importer = CKANImporter(package) else: importer = CKANImporter(package, args.mapping, args.resource) importer.run(**vars(args)) return 0