Total Complexity | 7 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from typing import Dict, Any |
||
2 | |||
3 | class Provider: |
||
4 | """Superclass for provider plugins""" |
||
5 | DEFAULT_OP_ARGS: Dict[Any, Any] = {} |
||
6 | |||
7 | @classmethod |
||
8 | def get_default_op_args(cls, processor): |
||
9 | return cls.DEFAULT_OP_ARGS.get(processor, dict()) |
||
10 | |||
11 | |||
12 | class TinkerGraph(Provider): # TODO |
||
13 | """Default provider""" |
||
14 | |||
15 | @staticmethod |
||
16 | def get_hashable_id(val): |
||
17 | return val |
||
18 | |||
19 | class JanusGraph(Provider): # TODO |
||
20 | """Default provider""" |
||
21 | |||
22 | @staticmethod |
||
23 | def get_hashable_id(val): |
||
24 | if not isinstance(val, dict): |
||
25 | return val |
||
26 | type_prop = val.get("@type", None) |
||
27 | if not type_prop == "janusgraph:RelationIdentifier": |
||
28 | return val |
||
29 | val_prop = val.get("@value", None) |
||
30 | if not isinstance(val_prop, dict): |
||
31 | return val |
||
32 | rel_prop = val_prop.get("relationId", None) |
||
33 | if not rel_prop: |
||
34 | return val |
||
35 | return rel_prop |
||
36 | |||
37 |