def filter_items(graph, cond, items = None): if isinstance(cond, basestring): if graph.grTriplesForSubj(cond): found = set([cond]) return found & items if items else found else: return set() if isinstance(cond, set): found = set([i for i in cond if graph.grTriplesForSubj(i)]) return found & items if items else found cond = condition_lift(cond) if not cond: return items found = set() if items: for uri in items: if cond.match(uri) and graph.grTriplesForSubj(uri): found.add(uri) else: for curi, s in graph.ks.iteritems(): if s: uri = expand_uri(curi) if cond.match(uri): found.add(uri) return found
def filter_items(graph, cond, items=None): if isinstance(cond, basestring): if graph.grTriplesForSubj(cond): found = set([cond]) return found & items if items else found else: return set() if isinstance(cond, set): found = set([i for i in cond if graph.grTriplesForSubj(i)]) return found & items if items else found cond = condition_lift(cond) if not cond: return items found = set() if items: for uri in items: if cond.match(uri) and graph.grTriplesForSubj(uri): found.add(uri) else: for curi, s in graph.ks.iteritems(): if s: uri = expand_uri(curi) if cond.match(uri): found.add(uri) return found
def write_graph(self, g): total = len(g.ks) count = 0 for curi, triples in g.ks.iteritems(): uri = expand_uri(curi) if uri.startswith('_#') and g.ko.get(curi) is not None: continue self.write_entity(g, uri, triples) count += 1 if count % 1000 == 0: st = getattr(g, 'AsyncChangeState', None) if st: # graph is Document g.AsyncChangeState(g.state_saving, 100*count/total)
def process_graph(self, g): total = len(g.ks) count = 0 kl = g.ks.keys() kl.sort() for ent in kl: eent = expand_uri(ent) if eent.startswith('_#') and g.ko.get(ent) is not None: continue self.write_entity(g, eent, g.ks[ent]) count += 1 if count % 1000 == 0: st = getattr(g, 'AsyncChangeState', None) if st: # graph is Document g.AsyncChangeState(g.state_saving, 100*count/total)
def process_graph(self, g): total = len(g.ks) count = 0 kl = g.ks.keys() kl.sort() for ent in kl: eent = expand_uri(ent) if eent.startswith('_#') and g.ko.get(ent) is not None: continue self.write_entity(g, eent, g.ks[ent]) count += 1 if count % 1000 == 0: st = getattr(g, 'AsyncChangeState', None) if st: # graph is Document g.AsyncChangeState(g.state_saving, 100 * count / total)