2121 AQLCacheConfigureError ,
2222 AQLCachePropertiesError
2323)
24+ from arango .formatter import (
25+ format_aql_cache ,
26+ format_aql_query ,
27+ format_aql_tracking
28+ )
2429from arango .request import Request
2530
2631
@@ -39,45 +44,6 @@ def __init__(self, connection, executor):
3944 def __repr__ (self ):
4045 return '<AQL in {}>' .format (self ._conn .db_name )
4146
42- # noinspection PyMethodMayBeStatic
43- def _format_tracking_properties (self , body ):
44- """Format the tracking properties.
45-
46- :param body: Response body.
47- :type body: dict
48- :return: Formatted body.
49- :rtype: dict
50- """
51- body .pop ('code' , None )
52- body .pop ('error' , None )
53- if 'maxQueryStringLength' in body :
54- body ['max_query_string_length' ] = body .pop ('maxQueryStringLength' )
55- if 'maxSlowQueries' in body :
56- body ['max_slow_queries' ] = body .pop ('maxSlowQueries' )
57- if 'slowQueryThreshold' in body :
58- body ['slow_query_threshold' ] = body .pop ('slowQueryThreshold' )
59- if 'trackBindVars' in body :
60- body ['track_bind_vars' ] = body .pop ('trackBindVars' )
61- if 'trackSlowQueries' in body :
62- body ['track_slow_queries' ] = body .pop ('trackSlowQueries' )
63- return body
64-
65- # noinspection PyMethodMayBeStatic
66- def _format_queries (self , body ):
67- """Format the list of queries.
68-
69- :param body: Response body.
70- :type body: dict
71- :return: Formatted body.
72- :rtype: dict
73- """
74- for query in body :
75- if 'bindVars' in query :
76- query ['bind_vars' ] = query .pop ('bindVars' )
77- if 'runTime' in query :
78- query ['runtime' ] = query .pop ('runTime' )
79- return body
80-
8147 @property
8248 def cache (self ):
8349 """Return the query cache API wrapper.
@@ -359,7 +325,7 @@ def queries(self):
359325 def response_handler (resp ):
360326 if not resp .is_success :
361327 raise AQLQueryListError (resp , request )
362- return self . _format_queries ( resp .body )
328+ return [ format_aql_query ( q ) for q in resp .body ]
363329
364330 return self ._execute (request , response_handler )
365331
@@ -378,7 +344,7 @@ def slow_queries(self):
378344 def response_handler (resp ):
379345 if not resp .is_success :
380346 raise AQLQueryListError (resp , request )
381- return self . _format_queries ( resp .body )
347+ return [ format_aql_query ( q ) for q in resp .body ]
382348
383349 return self ._execute (request , response_handler )
384350
@@ -416,7 +382,7 @@ def tracking(self):
416382 def response_handler (resp ):
417383 if not resp .is_success :
418384 raise AQLQueryTrackingGetError (resp , request )
419- return self . _format_tracking_properties (resp .body )
385+ return format_aql_tracking (resp .body )
420386
421387 return self ._execute (request , response_handler )
422388
@@ -456,7 +422,7 @@ def set_tracking(self,
456422 def response_handler (resp ):
457423 if not resp .is_success :
458424 raise AQLQueryTrackingSetError (resp , request )
459- return self . _format_tracking_properties (resp .body )
425+ return format_aql_tracking (resp .body )
460426
461427 return self ._execute (request , response_handler )
462428
@@ -554,28 +520,6 @@ class AQLQueryCache(APIWrapper):
554520 def __repr__ (self ):
555521 return '<AQLQueryCache in {}>' .format (self ._conn .db_name )
556522
557- # noinspection PyMethodMayBeStatic
558- def _format_cache_properties (self , body ):
559- """Format the query cache properties.
560-
561- :param body: Response body.
562- :type body: dict
563- :return: Formatted body.
564- :rtype: dict
565- """
566- body .pop ('code' , None )
567- body .pop ('error' , None )
568-
569- if 'maxResults' in body :
570- body ['max_results' ] = body .pop ('maxResults' )
571- if 'maxResultsSize' in body :
572- body ['max_results_size' ] = body .pop ('maxResultsSize' )
573- if 'maxEntrySize' in body :
574- body ['max_entry_size' ] = body .pop ('maxEntrySize' )
575- if 'includeSystem' in body :
576- body ['include_system' ] = body .pop ('includeSystem' )
577- return body
578-
579523 def properties (self ):
580524 """Return the query cache properties.
581525
@@ -591,7 +535,7 @@ def properties(self):
591535 def response_handler (resp ):
592536 if not resp .is_success :
593537 raise AQLCachePropertiesError (resp , request )
594- return self . _format_cache_properties (resp .body )
538+ return format_aql_cache (resp .body )
595539
596540 return self ._execute (request , response_handler )
597541
@@ -642,7 +586,7 @@ def configure(self,
642586 def response_handler (resp ):
643587 if not resp .is_success :
644588 raise AQLCacheConfigureError (resp , request )
645- return self . _format_cache_properties (resp .body )
589+ return format_aql_cache (resp .body )
646590
647591 return self ._execute (request , response_handler )
648592
0 commit comments