def load(self): ## # Checking command given options ## url = self.options.url filename = self.options.filename format = self.options.format if not url and not filename: print "ERROR: No URL or FILENAME provided and one is required" print self.usage return vocab_name = self.options.name if not vocab_name: print "ERROR: No vocabulary name provided and is required" print self.usage return if vocab_name not in self._controlled_vocabularies_allowed: print "ERROR: Incorrect vocabulary name, only one of these values are allowed: {0}".format( self._controlled_vocabularies_allowed) print self.usage return if vocab_name == LICENSES_NAME: clear_licenses() load_licenses_from_graph(filename, url) Session.commit() return if vocab_name == SUBTHEME_NAME: clear_subthemes() theme_map = self.options.filename try: eurovoc = self.args[-1] except IndexError: print "ERROR: Missing eurovoc file" print self.usage return load_subthemes(theme_map, eurovoc) Session.commit() return do_load(vocab_name, url=url, filename=filename, format=format)
def load(g, name, uri, eurovoc): if name == LICENSES_NAME: ret = {'licenses_deleted': License.count()} clear_licenses() load_licenses(g) ret['licenses_created'] = License.count() Session.commit() return ret if name == SUBTHEME_NAME: ret = {'subthemes_deleted': Subtheme.count()} clear_subthemes() load_subthemes(None, eurovoc, themes_g=g) ret['subthemes_created'] = Subtheme.count() Session.commit() return ret return do_load(g, name)