Mercurial > code > home > repos > homeauto
annotate service/reasoning/graphop.py @ 1562:c2ed44ed1e3c dependabot/pip/service/collector/twisted-19.7.0
Bump twisted from 19.2.0 to 19.7.0 in /service/collector
Bumps [twisted](https://github.com/twisted/twisted) from 19.2.0 to 19.7.0.
- [Release notes](https://github.com/twisted/twisted/releases)
- [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst)
- [Commits](https://github.com/twisted/twisted/compare/twisted-19.2.0...twisted-19.7.0)
Signed-off-by: dependabot[bot] <support@github.com>
author | dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
---|---|
date | Fri, 14 Feb 2020 10:01:26 +0000 |
parents | d36d3b9ae516 |
children |
rev | line source |
---|---|
854 | 1 import logging |
2 from rdflib import URIRef, ConjunctiveGraph | |
1556
d36d3b9ae516
python 3! and some types and cleanups
drewp <drewp@bigasterisk.com>
parents:
984
diff
changeset
|
3 from typing import List |
854 | 4 log = logging.getLogger() |
853 | 5 |
1556
d36d3b9ae516
python 3! and some types and cleanups
drewp <drewp@bigasterisk.com>
parents:
984
diff
changeset
|
6 |
d36d3b9ae516
python 3! and some types and cleanups
drewp <drewp@bigasterisk.com>
parents:
984
diff
changeset
|
7 def graphWithoutMetadata(g: ConjunctiveGraph, ignorePredicates=[]): |
853 | 8 """ |
9 graph filter that removes any statements whose subjects are | |
10 contexts in the graph and also any statements with the given | |
11 predicates | |
12 """ | |
984
5da9200418db
reasoning: -v verbose setting, more oneshot support, some custom stuff for mpd commands
drewp <drewp@bigasterisk.com>
parents:
923
diff
changeset
|
13 |
5da9200418db
reasoning: -v verbose setting, more oneshot support, some custom stuff for mpd commands
drewp <drewp@bigasterisk.com>
parents:
923
diff
changeset
|
14 ctxs = [ctx.identifier for ctx in g.contexts()] |
853 | 15 |
16 out = ConjunctiveGraph() | |
17 for stmt in g.quads((None, None, None)): | |
18 if stmt[0] not in ctxs and stmt[1] not in ignorePredicates: | |
19 out.addN([stmt]) | |
20 return out | |
21 | |
1556
d36d3b9ae516
python 3! and some types and cleanups
drewp <drewp@bigasterisk.com>
parents:
984
diff
changeset
|
22 |
d36d3b9ae516
python 3! and some types and cleanups
drewp <drewp@bigasterisk.com>
parents:
984
diff
changeset
|
23 def graphEqual(a: ConjunctiveGraph, b: ConjunctiveGraph, |
d36d3b9ae516
python 3! and some types and cleanups
drewp <drewp@bigasterisk.com>
parents:
984
diff
changeset
|
24 ignorePredicates: List[URIRef]=[]): |
853 | 25 """ |
26 compare graphs, omitting any metadata statements about contexts | |
27 (especially modification times) and also any statements using the | |
28 given predicates | |
29 """ | |
30 stmtsA = set(graphWithoutMetadata(a, ignorePredicates)) | |
31 stmtsB = set(graphWithoutMetadata(b, ignorePredicates)) | |
32 if stmtsA == stmtsB: | |
33 return True | |
1556
d36d3b9ae516
python 3! and some types and cleanups
drewp <drewp@bigasterisk.com>
parents:
984
diff
changeset
|
34 |
853 | 35 if log.getEffectiveLevel() <= logging.INFO: |
36 lost = stmtsA - stmtsB | |
37 if lost: | |
923
4ae49c6adecb
errors and logging in reasoning
drewp <drewp@bigasterisk.com>
parents:
854
diff
changeset
|
38 log.info("graph A only:") |
853 | 39 for s in lost: |
40 log.info(" %s", s) | |
41 new = stmtsB - stmtsA | |
42 if new: | |
923
4ae49c6adecb
errors and logging in reasoning
drewp <drewp@bigasterisk.com>
parents:
854
diff
changeset
|
43 log.info("graph B only:") |
853 | 44 for s in new: |
45 log.info(" %s", s) | |
46 return False |