11import logging
2- from aperturedb import CSVParser
2+ from aperturedb .CSVParser import CSVParser , CONSTRAINTS_PREFIX
3+ from aperturedb .Query import QueryBuilder
34
45logger = logging .getLogger (__name__ )
56
89CONSTRAINTS = "constraints"
910
1011
11- class ConnectionDataCSV (CSVParser . CSVParser ):
12+ class ConnectionDataCSV (CSVParser ):
1213 """**ApertureDB Connection Data.**
1314
1415 This class loads the Connection Data which is present in a csv file,
@@ -57,10 +58,10 @@ def __init__(self, filename, df=None, use_dask=False):
5758 super ().__init__ (filename , df = df , use_dask = use_dask )
5859 if not use_dask :
5960 self .props_keys = [x for x in self .header [3 :]
60- if not x .startswith (CSVParser . CONTRAINTS_PREFIX )]
61+ if not x .startswith (CONSTRAINTS_PREFIX )]
6162
6263 self .constraints_keys = [x for x in self .header [3 :]
63- if x .startswith (CSVParser . CONTRAINTS_PREFIX )]
64+ if x .startswith (CONSTRAINTS_PREFIX )]
6465
6566 self .src_class = self .header [1 ].split ("@" )[0 ]
6667 self .src_key = self .header [1 ].split ("@" )[1 ]
@@ -77,34 +78,25 @@ def getitem(self, idx):
7778 q = []
7879
7980 try :
80-
8181 ref_src = (2 * idx ) % 100000 + 1
82- fe_a = {
83- "FindEntity " : {
84- "_ref " : ref_src ,
85- "with_class " : self . src_class ,
86- "unique" : True ,
82+ cmd_params = {
83+ "_ref " : ref_src ,
84+ "unique " : True ,
85+ "constraints " : {
86+ self . src_key : [ "==" , src_value ]
8787 }
8888 }
89-
90- fe_a ["FindEntity" ]["constraints" ] = {}
91- fe_a ["FindEntity" ]["constraints" ][self .src_key ] = [
92- "==" , src_value ]
93- q .append (fe_a )
89+ q .append (QueryBuilder .find_command (self .src_class , cmd_params ))
9490
9591 ref_dst = ref_src + 1
96- fe_b = {
97- "FindEntity " : {
98- "_ref " : ref_dst ,
99- "with_class " : self . dst_class ,
100- "unique" : True ,
92+ cmd_params = {
93+ "_ref " : ref_dst ,
94+ "unique " : True ,
95+ "constraints " : {
96+ self . dst_key : [ "==" , dst_value ]
10197 }
10298 }
103-
104- fe_b ["FindEntity" ]["constraints" ] = {}
105- fe_b ["FindEntity" ]["constraints" ][self .dst_key ] = [
106- "==" , dst_value ]
107- q .append (fe_b )
99+ q .append (QueryBuilder .find_command (self .dst_class , cmd_params ))
108100
109101 ae = self ._basic_command (idx ,
110102 custom_fields = {
0 commit comments