def _load_schema_module_path(url): """ Given a path like "ckanext.spatialx:spatialx_schema.json" find the second part relative to the import path of the first """ module, file_name = url.split(':', 1) try: # __import__ has an odd signature m = __import__(module, fromlist=['']) except ImportError: return p = os.path.join(os.path.dirname(inspect.getfile(m)), file_name) if os.path.exists(p): return loader.load(open(p))
""" Given a path like "ckanext.spatialx:spatialx_schema.json" find the second part relative to the import path of the first """ log.debug("Schema URL is {0}".format(url)) module, file_name = url.split(':', 1) try: # __import__ has an odd signature m = __import__(module, fromlist=['']) except ImportError, e: log.error("Could not load lodule {0}, got {1}".format(module, e)) return p = os.path.join(os.path.dirname(inspect.getfile(m)), file_name) if os.path.exists(p): watch_file(p) return loader.load(open(p)) def _load_schema_url(url): import urllib2 try: res = urllib2.urlopen(url) tables = res.read() except urllib2.URLError: raise SchemingException("Could not load %s" % url) return loader.loads(tables, url) def _field_output_validators_group(f, schema, convert_extras): """