def checkDryad(self): # Test reading data from Dryad item = ItemFactory.make(self.mydao, app.config["PROVIDERS"]) item.aliases.add_alias('doi', '10.5061/dryad.7898') item_aliases_list = item.aliases.get_aliases_list() dryad = Dryad() new_aliases = dryad.aliases(item_aliases_list) new_metrics = dryad.metrics(item_aliases_list) self.check_aliases('dryad.url', new_aliases, ("url", 'http://hdl.handle.net/10255/dryad.7898')) self.check_aliases('dryad.title', new_aliases, ("title", 'data from: can clone size serve as a proxy for clone age? an exploration using microsatellite divergence in populus tremuloides'))
def first(self): if self.none_count >= 3: if self.max_items: if self.current_item > self.max_items: return None # Generate a mock item with initial alias ('mock', id) item = ItemFactory.make() item.id = self.current_item item.aliases['mock'] = str(item.id) self.items[self.current_item] = item return item else: self.none_count += 1 return None
def checkWikipedia(self): # Test reading data from Wikipedia item = ItemFactory.make(self.mydao, app.config["PROVIDERS"]) item.aliases.add_alias("doi", "10.1371/journal.pcbi.1000361") #item.aliases.add_alias("url", "http://cottagelabs.com") item_aliases_list = item.aliases.get_aliases_list() wikipedia = Wikipedia() # No aliases for wikipedia #new_aliases = wikipedia.aliases(item_aliases_list) new_metrics = wikipedia.metrics(item_aliases_list) self.check_metric('wikipedia:mentions', new_metrics['wikipedia:mentions'], 1)
def create_item(namespace, nid): logger.debug("In create_item with alias" + str((namespace, nid))) item = ItemFactory.make() # set this so we know when it's still updating later on myredis.set_num_providers_left(item["_id"], ProviderFactory.num_providers_with_metrics(default_settings.PROVIDERS)) item["aliases"][namespace] = [nid] mydao.save(item) myredis.add_to_alias_queue(item["_id"], item["aliases"]) logger.info("Created new item '{id}' with alias '{alias}'".format(id=item["_id"], alias=str((namespace, nid)))) try: return item["_id"] except AttributeError: abort(500)
def create_item(namespace, id): '''Utility function to keep DRY in single/multiple item creation endpoins''' item = ItemFactory.make(mydao, app.config["PROVIDERS"]) item.aliases.add_alias(namespace, id) ## FIXME - see issue 86 ## Should look up this namespace and id and see if we already have a tiid ## If so, return its tiid with a 200. # right now this makes a new item every time, creating many dupes # does not filter by whether we actually can process the namespace, since # we may be able to someday soon. It's user's job to not pass in junk. item.save() try: return item.id except AttributeError: abort(500)
def checkGithub(self): item = ItemFactory.make(self.mydao, app.config["PROVIDERS"]) github = Github() members = github.member_items("egonw") self.check_members('github.github_user', members, [('github', ('egonw', 'blueobelisk.debian')), ('github', ('egonw', 'ron')), ('github', ('egonw', 'pubchem-cdk')), ('github', ('egonw', 'org.openscience.cdk')), ('github', ('egonw', 'java-rdfa')), ('github', ('egonw', 'cdk')), ('github', ('egonw', 'RobotDF')), ('github', ('egonw', 'egonw.github.com')), ('github', ('egonw', 'knime-chemspider')), ('github', ('egonw', 'gtd')), ('github', ('egonw', 'cheminfbenchmark')), ('github', ('egonw', 'cdk-taverna')), ('github', ('egonw', 'groovy-jcp')), ('github', ('egonw', 'jnchem')), ('github', ('egonw', 'acsrdf2010')), ('github', ('egonw', 'Science-3.0')), ('github', ('egonw', 'SNORQL')), ('github', ('egonw', 'ctr-cdk-groovy')), ('github', ('egonw', 'CDKitty')), ('github', ('egonw', 'rednael')), ('github', ('egonw', 'de.ipbhalle.msbi')), ('github', ('egonw', 'collaborative.cheminformatics')), ('github', ('egonw', 'xws-taverna')), ('github', ('egonw', 'cheminformatics.classics')), ('github', ('egonw', 'chembl.rdf')), ('github', ('egonw', 'blueobelisk.userscript')), ('github', ('egonw', 'ojdcheck')), ('github', ('egonw', 'nmrshiftdb-rdf')), ('github', ('egonw', 'bioclipse.ons')), ('github', ('egonw', 'medea_bmc_article'))]) item.aliases.add_alias("github", "egonw,gtd") item_aliases_list = item.aliases.get_aliases_list() new_metrics = github.metrics(item_aliases_list) self.check_metric('github:forks', new_metrics['github:forks'], 0) self.check_metric('github:watchers', new_metrics['github:watchers'], 7)
def create_or_find_items_from_aliases(clean_aliases): tiids = [] items = [] for alias in clean_aliases: (namespace, nid) = alias existing_tiid = get_tiid_by_alias(namespace, nid) if existing_tiid: tiids.append(existing_tiid) logger.debug( "found an existing tiid ({tiid}) for alias {alias}".format(tiid=existing_tiid, alias=str(alias)) ) else: logger.debug("alias {alias} isn't in the db; making a new item for it.".format(alias=alias)) item = ItemFactory.make() item["aliases"][namespace] = [nid] items.append(item) tiids.append(item["_id"]) return (tiids, items)