def get_data(cls, project_identifier, fuzzy=False): result = None url = "http://www.opensourcebrain.org/projects/%s.json"%project_identifier page = get_page('%s' % (url), utf8=True) json_data = json.loads(page) if 'project' in json_data: result = json_data['project'] if result is None: print("No project with identifier %s" % project_identifier) if fuzzy: projects_identifiers = get_projects_identifiers() for candidate_project_identifier in projects_identifiers: p = project_identifier.lower() c = candidate_project_identifier match = (p in c) or (c in p) or \ (p.replace('-','') in c) or \ (c in p.replace('-','')) or \ (p.replace('_','') in c) or \ (c in p.replace('_','')) if match: print("Using project with similar identifier %s" \ % c) result = cls.get_data(c) break return result
def create(github_repo_str): if github_repo_str is None: print("Empty github_repo_str") return None if github_repo_str.endswith(".git"): github_repo_str = github_repo_str[:-4] if not github_repo_str.startswith('https://github.com'): print("Incorrectly formatted github_repo_str: %s"%github_repo_str) return None if not len(github_repo_str.split('/')) == 5: print("Incorrectly formatted github_repo_str: %s"%github_repo_str) return None repo = "https://api.github.com/repos/"+github_repo_str[19:] page = get_page(repo, utf8=True) gh = json.loads(page) '''for g in gh: print("%s = <<%s>>"%(g, gh[g]))''' ghr = GitHubRepository(gh) return ghr
def list_files_in_repo(self): rest_url = self.list_files_template%(self.full_name) #print("URL: %s"%rest_url) w = get_page(rest_url, utf8=True) json_files = json.loads(w) if not 'tree' in json_files: print("Error!") print(json_files) files = [] tree = json_files["tree"] for entry in tree: files.append(entry["path"]) return files
def get_projects_data(min_curation_level, limit=1000): url = "http://www.opensourcebrain.org/projects.json" page = get_page('%s?limit=%d' % (url,limit), utf8=True) json_data = json.loads(page) projects_data_all = json_data['projects'] projects_data = [] for project_data in projects_data_all: curation_level = 0 text = "Curation level" if get_custom_field(project_data, text): curation_level = int(get_custom_field(project_data, text)) if (min_curation_level in ["None",None,"",0]) or \ (min_curation_level in ["Low",1] and curation_level>=1) or \ (min_curation_level in ["Medium",2] and curation_level>=2) or \ (min_curation_level in ["High",3] and curation_level>=3): projects_data.append(project_data) return projects_data
def get_projects_data(min_curation_level, limit=1000, url = LIVE_URL, verbose=False): page_url = '%s?limit=%d' % (url,limit) if verbose: print("> Requesting page: %s..."%page_url) page = get_page(page_url, utf8=True) json_data = json.loads(page) projects_data_all = json_data['projects'] projects_data = [] for project_data in projects_data_all: curation_level = 0 text = "Curation level" if get_custom_field(project_data, text): curation_level = int(get_custom_field(project_data, text)) if (min_curation_level in ["None",None,"",0]) or \ (min_curation_level in ["Low",1] and curation_level>=1) or \ (min_curation_level in ["Medium",2] and curation_level>=2) or \ (min_curation_level in ["High",3] and curation_level>=3): projects_data.append(project_data) return projects_data
for file in files: if is_nml2_file(file): desc = Description(file) raw_url = github_repo.link_to_raw_file_in_repo(file) comment = "NeuroML 2 file: %s (at %s)"%(file,raw_url) rdf.descriptions.append(desc) # It's a computational neuroscience model add_simple_qualifier(desc, \ 'bqmodel', \ 'is', \ raw_url, \ "") contents = get_page(raw_url) print(" Building NeuroML doc from: "+raw_url) cno_type = None doc = parseString(contents) if doc.notes: comment += "\n%s"%doc.notes for ion_channel in doc.ion_channel: cno_type = 'ionic current model' if ion_channel.notes: comment += "\n Ion Channel: %s; %s"%(ion_channel.id, ion_channel.notes) channel_type = 'ion channel complex' if ion_channel.species: if ion_channel.species == "ca":
if is_nml2_file(file): desc = Description(file) raw_url = github_repo.link_to_raw_file_in_repo(file) comment = "NeuroML 2 file: %s (at %s)"%(file,raw_url) rdf.descriptions.append(desc) # It's a computational neuroscience model add_simple_qualifier(desc, \ 'bqmodel', \ 'is', \ raw_url, \ "") print(" Building NeuroML doc from: "+raw_url) contents = get_page(raw_url, utf8=True) cno_type = None doc = parseString(contents) if doc.notes: comment += "\n%s"%doc.notes for ion_channel in doc.ion_channel: cno_type = 'ionic current model' if ion_channel.notes: comment += "\n Ion Channel: %s; %s"%(ion_channel.id, ion_channel.notes) channel_type = 'ion channel complex' if ion_channel.species: if ion_channel.species == "ca": channel_type = 'calcium channel complex'