@@ -101,7 +101,7 @@ def __init__(self, left, op, right, parent=None):
101101
102102 Groups may have a reference to their parent.
103103 """
104- if not op in self .LEGAL_OPS :
104+ if op not in self .LEGAL_OPS :
105105 raise TypeError (op + " is not a legal logical operation" )
106106 self .parent = parent
107107 self .left = left
@@ -151,7 +151,8 @@ class LogicParseError(ReadableException):
151151
152152class EmptyLogicError (ValueError ):
153153 """
154- An error representing the fact that an the logic string to be parsed was empty
154+ An error representing the fact that an the logic
155+ string to be parsed was empty
155156 """
156157 pass
157158
@@ -269,7 +270,7 @@ def dedouble(x):
269270 return x
270271
271272 logic_str = logic_str .upper ()
272- tokens = [t for t in re .split ("\s+" , logic_str ) if t ]
273+ tokens = [t for t in re .split ("\\ s+" , logic_str ) if t ]
273274 if not tokens :
274275 raise EmptyLogicError ()
275276 tokens = flatten ([canonical (x , self .ops ) for x in tokens ])
@@ -288,8 +289,10 @@ def check_syntax(self, infix_tokens):
288289 which should hopefully lead to more informative error messages.
289290
290291 This checks for:
291- - correct operator positions (cannot put two codes next to each other without intervening operators)
292- - correct grouping (all brackets are matched, and contain valid expressions)
292+ - correct operator positions (cannot put two codes next to each
293+ other without intervening operators)
294+ - correct grouping (all brackets are matched,
295+ and contain valid expressions)
293296
294297 @param infix_tokens: The input parsed into a list of tokens.
295298 @type infix_tokens: iterable
@@ -303,22 +306,29 @@ def check_syntax(self, infix_tokens):
303306 for token in infix_tokens :
304307 if token not in self .ops :
305308 if need_an_op :
306- raise LogicParseError ("Expected an operator after: '" + ' ' .join (processed ) + "'"
309+ raise LogicParseError ("Expected an operator after: '"
310+ + ' ' .join (processed ) + "'"
307311 + " - but got: '" + token + "'" )
308312 if need_binary_op_or_closing_bracket :
309- raise LogicParseError ("Logic grouping error after: '" + ' ' .join (processed ) + "'"
310- + " - expected an operator or a closing bracket" )
313+ raise LogicParseError ("Logic grouping error after: '"
314+ + ' ' .join (processed ) + "'"
315+ + " - expected an operator "
316+ "or a closing bracket" )
311317
312318 need_an_op = True
313319 else :
314320 need_an_op = False
315321 if token == "(" :
316322 if processed and processed [- 1 ] not in self .ops :
317- raise LogicParseError ("Logic grouping error after: '" + ' ' .join (processed ) + "'"
318- + " - got an unexpeced opening bracket" )
323+ raise LogicParseError ("Logic grouping error after: '"
324+ + ' ' .join (processed ) + "'"
325+ + " - got an unexpeced "
326+ "opening bracket" )
319327 if need_binary_op_or_closing_bracket :
320- raise LogicParseError ("Logic grouping error after: '" + ' ' .join (processed ) + "'"
321- + " - expected an operator or a closing bracket" )
328+ raise LogicParseError ("Logic grouping error after: '"
329+ + ' ' .join (processed ) + "'"
330+ + " - expected an operator or "
331+ "a closing bracket" )
322332
323333 open_brackets += 1
324334 elif token == ")" :
@@ -332,7 +342,8 @@ def check_syntax(self, infix_tokens):
332342 message = "Unmatched closing bracket in: "
333343 else :
334344 message = "Unmatched opening bracket in: "
335- raise LogicParseError (message + '"' + ' ' .join (infix_tokens ) + '"' )
345+ raise LogicParseError (message + '"' + ' ' .join (infix_tokens )
346+ + '"' )
336347
337348 def infix_to_postfix (self , infix_tokens ):
338349 """
@@ -368,7 +379,8 @@ def infix_to_postfix(self, infix_tokens):
368379 else :
369380 postfix_tokens .append (last_op )
370381 else :
371- while stack and self .get_priority (stack [- 1 ]) <= self .get_priority (op ):
382+ while stack and (self .get_priority (stack [- 1 ])
383+ <= self .get_priority (op )):
372384 prev_op = stack .pop ()
373385 if prev_op != "(" :
374386 postfix_tokens .append (prev_op )
@@ -519,7 +531,8 @@ def __init__(self, path, op, value, code="A"):
519531 @param path: The path to constrain
520532 @type path: string
521533
522- @param op: The relationship between the value represented by the path and the value provided (must be a valid operator)
534+ @param op: The relationship between the value represented by the path
535+ and the value provided (must be a valid operator)
523536 @type op: string
524537
525538 @param value: The value to compare the stored value to
@@ -572,8 +585,8 @@ class ListConstraint(CodedConstraint):
572585 def __init__ (self , path , op , list_name , code = "A" ):
573586 if hasattr (list_name , 'to_query' ):
574587 q = list_name .to_query ()
575- l = q .service .create_list (q )
576- self .list_name = l .name
588+ list_name1 = q .service .create_list (q )
589+ self .list_name = list_name1 .name
577590 elif hasattr (list_name , "name" ):
578591 self .list_name = list_name .name
579592 else :
@@ -625,7 +638,8 @@ def __init__(self, path, op, loopPath, code="A"):
625638 @param path: The path to constrain
626639 @type path: string
627640
628- @param op: The relationship between the path and the path provided (must be a valid operator)
641+ @param op: The relationship between the path and the path provided
642+ (must be a valid operator)
629643 @type op: string
630644
631645 @param loopPath: The path to check for identity against
@@ -677,18 +691,21 @@ def __init__(self, path, op, value, extra_value=None, code="A"):
677691 Constructor
678692 ===========
679693
680- @param path: The path to constrain. Here is must be a class, or a reference to a class.
694+ @param path: The path to constrain. Here is must be a class,
695+ or a reference to a class.
681696 @type path: string
682697
683- @param op: The relationship between the path and the path provided (must be a valid operator)
698+ @param op: The relationship between the path and the path provided
699+ (must be a valid operator)
684700 @type op: string
685701
686702 @param value: The value to check other fields against.
687703 @type value: string
688704
689- @param extra_value: A further value for disambiguation. The meaning of this value varies by class
690- and configuration. For example, if the class of the object is Gene, then
691- extra_value will refer to the Organism.
705+ @param extra_value: A further value for disambiguation. The meaning
706+ of this value varies by class and configuration.
707+ For example, if the class of the object is Gene,
708+ then extra_value will refer to the Organism.
692709 @type extra_value: string
693710
694711 @param code: The code for this constraint (default = "A")
@@ -746,13 +763,16 @@ def __init__(self, path, op, values, code="A"):
746763 Constructor
747764 ===========
748765
749- @param path: The path to constrain. Here it must be an attribute of some object.
766+ @param path: The path to constrain. Here it must be an attribute of
767+ some object.
750768 @type path: string
751769
752- @param op: The relationship between the path and the path provided (must be a valid operator)
770+ @param op: The relationship between the path and the path provided
771+ (must be a valid operator)
753772 @type op: string
754773
755- @param values: The set of values which the object of the constraint either must or must not belong to.
774+ @param values: The set of values which the object of the constraint
775+ either must or must not belong to.
756776 @type values: set or list
757777
758778 @param code: The code for this constraint (default = "A")
@@ -803,9 +823,9 @@ class RangeConstraint(MultiConstraint):
803823
804824 4 WITHIN [1..5, 20..25] => True
805825
806- The format of the ranges depends on the value being constrained and what range
807- parsers have been configured on the target server. A common range parser for
808- biological mines is the one for Locations:
826+ The format of the ranges depends on the value being constrained and what
827+ range parsers have been configured on the target server. A common range
828+ parser for biological mines is the one for Locations:
809829
810830 Gene.chromosomeLocation OVERLAPS [2X:54321..67890, 3R:12345..456789]
811831
@@ -857,10 +877,12 @@ def __init__(self, path, subclass):
857877 Constructor
858878 ===========
859879
860- @param path: The path to constrain. This must refer to a class or a reference to a class.
880+ @param path: The path to constrain. This must refer to a class or a
881+ reference to a class.
861882 @type path: str
862883
863- @param subclass: The class to subclass the path to. This must be a simple class name (not a dotted name)
884+ @param subclass: The class to subclass the path to. This must be a
885+ simple class name (not a dotted name)
864886 @type subclass: str
865887 """
866888 if not PATH_PATTERN .match (subclass ):
@@ -891,11 +913,13 @@ class TemplateConstraint(object):
891913 A mixin to supply the behaviour and state of constraints on templates
892914 =====================================================================
893915
894- Constraints on templates can also be designated as "on", "off" or "locked", which refers
895- to whether they are active or not. Inactive constraints are still configured, but behave
896- as if absent for the purpose of results. In addition, template constraints can be
897- editable or not. Only values for editable constraints can be provided when requesting results,
898- and only constraints that can participate in logic expressions can be editable.
916+ Constraints on templates can also be designated as "on", "off" or
917+ "locked", which refers to whether they are active or not. Inactive
918+ constraints are still configured, but behave as if absent for the purpose
919+ of results. In addition, template constraints can be editable or not.
920+ Only values for editable constraints can be provided when requesting
921+ results, and only constraints that can participate in logic expressions
922+ can be editable.
899923 """
900924 REQUIRED = "locked"
901925 OPTIONAL_ON = "on"
@@ -906,10 +930,12 @@ def __init__(self, editable=True, optional="locked"):
906930 Constructor
907931 ===========
908932
909- @param editable: Whether or not this constraint should accept new values.
933+ @param editable: Whether or not this constraint should accept new
934+ values.
910935 @type editable: bool
911936
912- @param optional: Whether a value for this constraint must be provided when running.
937+ @param optional: Whether a value for this constraint must be provided
938+ when running.
913939 @type optional: "locked", "on" or "off"
914940 """
915941 self .editable = editable
@@ -997,9 +1023,9 @@ def separate_arg_sets(self, args):
9971023
9981024 dict -> (dict, dict)
9991025
1000- Splits a dictionary of arguments into two separate dictionaries, one with
1001- arguments for the main constraint, and one with arguments for the template
1002- portion of the behaviour
1026+ Splits a dictionary of arguments into two separate dictionaries, one
1027+ with arguments for the main constraint, and one with arguments for the
1028+ template portion of the behaviour
10031029 """
10041030 c_args = {}
10051031 t_args = {}
@@ -1170,7 +1196,8 @@ def __init__(self):
11701196 Creates a new ConstraintFactory
11711197 """
11721198 self ._codes = iter (string .ascii_uppercase )
1173- self .reference_ops = TernaryConstraint .OPS | RangeConstraint .OPS | ListConstraint .OPS | IsaConstraint .OPS
1199+ self .reference_ops = (TernaryConstraint .OPS | RangeConstraint .OPS
1200+ | ListConstraint .OPS | IsaConstraint .OPS )
11741201
11751202 def get_next_code (self ):
11761203 """
0 commit comments