def alphasortkey(keyvalue): key, value = keyvalue if key is None: return ('z' * 10,) if '>' in key: key = key.split('>', 1)[-1] return natsort(key)
def _triples(self): self._prov_dict = {} combined_record, struct_prov, _, abbrev_prov = self.records() for k, v in self.fixes_prov.items(): if k in struct_prov: struct_prov[k].extend(v) else: struct_prov[k] = v for i, (abrv, (alts, (structure, *extras), figures, artifacts)) in enumerate( sorted(list(combined_record.items()) + list(self.fixes), key=lambda d: natsort(d[1][1][0] if d[1][1][ 0] is not None else 'zzzzzzzzzzzzzzzzzzzz')) ): # sort by structure not abrev iri = self.namespace[str(i + 1)] # TODO load from existing struct = structure if structure else 'zzzzzz' self._prov(iri, abrv, struct, struct_prov, extras, alts, abbrev_prov) yield from Label( labelRoot=self.root, #ifail='i fail!', # this indeed does fail label=struct, altLabel=None, synonyms=extras, abbrevs=( abrv, *alts), # FIXME make sure to check that it is not a string iri= iri, # FIXME error reporint if you try to put in abrv is vbad #extra_triples = str(processed_figures), # TODO ) processed_figures = figures # TODO these are handled in regions pass to PaxRegions if figures: for artifact in artifacts: PaxRegion.addthing( iri, figures) # artifact is baked into figures for t, pairs in self._prov_dict.items(): if pairs: yield from annotations(pairs, *t)
def edkey(line): ed, label, *rest = line.split('|', 2) return natsort(ed + ' ' + label)
def labelkey(line): label, *rest = line.split('|', 1) return natsort(label)