code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def bar_(self, label=None, style=None, opts=None, options={}):
try:
return self._get_chart("bar", style=style, opts=opts, label=label,
options=options)
except Exception as e:
self.err(e, self.bar_, "Can not draw bar chart")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bar_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '16', 'type': 'dictionary', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'try_statement', 'children': ['19', '39']}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_get_chart'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '30', '33', '36']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"bar"'}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '39', 'type': 'except_clause', 'children': ['40', '44']}; {'id': '40', 'type': 'as_pattern', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '42', 'type': 'as_pattern_target', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52', '55']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'bar_'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"Can not draw bar chart"'}
|
Get a bar chart
|
def getmodule(object):
if ismodule(object):
return object
if isclass(object):
return sys.modules.get(object.__module__)
try:
file = getabsfile(object)
except TypeError:
return None
if modulesbyfile.has_key(file):
return sys.modules[modulesbyfile[file]]
for module in sys.modules.values():
if hasattr(module, '__file__'):
modulesbyfile[getabsfile(module)] = module.__name__
if modulesbyfile.has_key(file):
return sys.modules[modulesbyfile[file]]
main = sys.modules['__main__']
if hasattr(main, object.__name__):
mainobject = getattr(main, object.__name__)
if mainobject is object:
return main
builtin = sys.modules['__builtin__']
if hasattr(builtin, object.__name__):
builtinobject = getattr(builtin, object.__name__)
if builtinobject is object:
return builtin
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getmodule'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '31', '45', '61', '89', '105', '113', '139', '147']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ismodule'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '19']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'isclass'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '__module__'}; {'id': '31', 'type': 'try_statement', 'children': ['32', '40']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'getabsfile'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '40', 'type': 'except_clause', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'if_statement', 'children': ['46', '52']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'modulesbyfile'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'has_key'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'modulesbyfile'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '61', 'type': 'for_statement', 'children': ['62', '63', '70']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '63', 'type': 'call', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'if_statement', 'children': ['72', '77']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'__file__'"}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '86']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'modulesbyfile'}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'getabsfile'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '89', 'type': 'if_statement', 'children': ['90', '96']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'modulesbyfile'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'has_key'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'subscript', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'modulesbyfile'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '108', 'type': 'subscript', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '112', 'type': 'string', 'children': [], 'value': "'__main__'"}; {'id': '113', 'type': 'if_statement', 'children': ['114', '121']}; {'id': '114', 'type': 'call', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '121', 'type': 'block', 'children': ['122', '132']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'mainobject'}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '127', 'type': 'argument_list', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '132', 'type': 'if_statement', 'children': ['133', '136']}; {'id': '133', 'type': 'comparison_operator', 'children': ['134', '135'], 'value': 'is'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'mainobject'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'return_statement', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'builtin'}; {'id': '142', 'type': 'subscript', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '146', 'type': 'string', 'children': [], 'value': "'__builtin__'"}; {'id': '147', 'type': 'if_statement', 'children': ['148', '155']}; {'id': '148', 'type': 'call', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '150', 'type': 'argument_list', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'builtin'}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '155', 'type': 'block', 'children': ['156', '166']}; {'id': '156', 'type': 'expression_statement', 'children': ['157']}; {'id': '157', 'type': 'assignment', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'builtinobject'}; {'id': '159', 'type': 'call', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '161', 'type': 'argument_list', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'builtin'}; {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '166', 'type': 'if_statement', 'children': ['167', '170']}; {'id': '167', 'type': 'comparison_operator', 'children': ['168', '169'], 'value': 'is'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'builtinobject'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '170', 'type': 'block', 'children': ['171']}; {'id': '171', 'type': 'return_statement', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'builtin'}
|
Return the module an object was defined in, or None if not found.
|
def _readhex(self, length, start):
if length % 4:
raise InterpretError("Cannot convert to hex unambiguously - "
"not multiple of 4 bits.")
if not length:
return ''
s = self._slice(start, start + length).tobytes()
try:
s = s.hex()
except AttributeError:
s = str(binascii.hexlify(s).decode('utf-8'))
return s[:-1] if (length // 4) % 2 else s
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_readhex'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '26', '42', '72']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '11'], 'value': '%'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'raise_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'InterpretError'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'concatenated_string', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Cannot convert to hex unambiguously - "'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"not multiple of 4 bits."'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '23']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "''"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '29', 'type': 'call', 'children': ['30', '41']}; {'id': '30', 'type': 'attribute', 'children': ['31', '40']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_slice'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '+'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tobytes'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'try_statement', 'children': ['43', '52']}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'hex'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'except_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '70']}; {'id': '62', 'type': 'attribute', 'children': ['63', '69']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'binascii'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'hexlify'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'conditional_expression', 'children': ['74', '80', '86'], 'value': 'if'}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '76', 'type': 'slice', 'children': ['77', '78']}; {'id': '77', 'type': 'colon', 'children': []}; {'id': '78', 'type': 'unary_operator', 'children': ['79'], 'value': '-'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '85'], 'value': '%'}; {'id': '81', 'type': '()', 'children': ['82']}; {'id': '82', 'type': 'binary_operator', 'children': ['83', '84'], 'value': '//'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 's'}
|
Read bits and interpret as a hex string.
|
def getRelativePath(basepath, path):
basepath = splitpath(os.path.abspath(basepath))
path = splitpath(os.path.abspath(path))
afterCommon = False
for c in basepath:
if afterCommon or path[0] != c:
path.insert(0, os.path.pardir)
afterCommon = True
else:
del path[0]
return os.path.join(*path)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getRelativePath'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'basepath'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '35', '39', '74']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'basepath'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'splitpath'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'basepath'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'splitpath'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'afterCommon'}; {'id': '38', 'type': 'False', 'children': []}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'basepath'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '51', '68']}; {'id': '44', 'type': 'boolean_operator', 'children': ['45', '46'], 'value': 'or'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'afterCommon'}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '50'], 'value': '!='}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '51', 'type': 'block', 'children': ['52', '64']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'pardir'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'afterCommon'}; {'id': '67', 'type': 'True', 'children': []}; {'id': '68', 'type': 'else_clause', 'children': ['69']}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'delete_statement', 'children': ['71']}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '81']}; {'id': '76', 'type': 'attribute', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'list_splat', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'path'}
|
Get a path that is relative to the given base path.
|
def cli(ctx, config, quiet):
ctx.obj = {}
ctx.obj['config'] = load_config(config.read())
ctx.obj['quiet'] = quiet
log(ctx, ' * ' + rnd_scotty_quote() + ' * ')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'quiet'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '29', '37']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '13', 'type': 'dictionary', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '21']}; {'id': '16', 'type': 'subscript', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'config'"}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'load_config'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '36']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'quiet'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'quiet'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '48'], 'value': '+'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '+'}; {'id': '44', 'type': 'string', 'children': [], 'value': "' * '"}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'rnd_scotty_quote'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'string', 'children': [], 'value': "' * '"}
|
AWS ECS Docker Deployment Tool
|
def _ReloadArtifacts(self):
self._artifacts = {}
self._LoadArtifactsFromFiles(self._sources.GetAllFiles())
self.ReloadDatastoreArtifacts()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ReloadArtifacts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '25']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_artifacts'}; {'id': '11', 'type': 'dictionary', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_LoadArtifactsFromFiles'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_sources'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'GetAllFiles'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ReloadDatastoreArtifacts'}; {'id': '30', 'type': 'argument_list', 'children': []}
|
Load artifacts from all sources.
|
def unregister_transform(self, node_class, transform, predicate=None):
self.transforms[node_class].remove((transform, predicate))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unregister_transform'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node_class'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'transform'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'predicate'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '20']}; {'id': '13', 'type': 'attribute', 'children': ['14', '19']}; {'id': '14', 'type': 'subscript', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'transforms'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'node_class'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'tuple', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'transform'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'predicate'}
|
Unregister the given transform.
|
def symbol(currency, *, native=True):
currency = validate_currency(currency)
if native:
return _currencies[currency]['symbol_native']
return _currencies[currency]['symbol']
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'symbol'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '5', 'type': 'keyword_separator', 'children': []}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'native'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '17', '26']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'validate_currency'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'native'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_currencies'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'symbol_native'"}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_currencies'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'currency'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'symbol'"}
|
return symbol of currency
|
def nice_true_ces(tc):
cause_list = []
next_list = []
cause = '<--'
effect = '-->'
for event in tc:
if event.direction == Direction.CAUSE:
cause_list.append(["{0:.4f}".format(round(event.alpha, 4)),
event.mechanism, cause, event.purview])
elif event.direction == Direction.EFFECT:
next_list.append(["{0:.4f}".format(round(event.alpha, 4)),
event.mechanism, effect, event.purview])
else:
validate.direction(event.direction)
true_list = [(cause_list[event], next_list[event])
for event in range(len(cause_list))]
return true_list
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nice_true_ces'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tc'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '18', '22', '107', '127']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'cause_list'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'next_list'}; {'id': '13', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cause'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'<--'"}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'effect'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'-->'"}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tc'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '34', '61', '96']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '31'], 'value': '=='}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'direction'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'Direction'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'CAUSE'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cause_list'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'list', 'children': ['42', '54', '57', '58'], 'value': '["{0:.4f}".format(round(event.alpha, 4)),\n event.mechanism, cause, event.purview]'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"{0:.4f}"'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'alpha'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'mechanism'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'cause'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'purview'}; {'id': '61', 'type': 'elif_clause', 'children': ['62', '69']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '66'], 'value': '=='}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'direction'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'Direction'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'EFFECT'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'next_list'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'list', 'children': ['77', '89', '92', '93'], 'value': '["{0:.4f}".format(round(event.alpha, 4)),\n event.mechanism, effect, event.purview]'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"{0:.4f}"'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'alpha'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'mechanism'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'effect'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'purview'}; {'id': '96', 'type': 'else_clause', 'children': ['97']}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'validate'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'direction'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'direction'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'true_list'}; {'id': '110', 'type': 'list_comprehension', 'children': ['111', '118']}; {'id': '111', 'type': 'tuple', 'children': ['112', '115']}; {'id': '112', 'type': 'subscript', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'cause_list'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '115', 'type': 'subscript', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'next_list'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '118', 'type': 'for_in_clause', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'call', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'cause_list'}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'true_list'}
|
Format a true |CauseEffectStructure|.
|
def create_and_run_collector(document, options):
collector = None
if not options.report == 'off':
collector = Collector()
collector.store.configure(document)
Event.configure(collector_queue=collector.queue)
collector.start()
return collector
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_and_run_collector'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'document'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '51']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'if_statement', 'children': ['12', '18']}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': '=='}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'off'"}; {'id': '18', 'type': 'block', 'children': ['19', '25', '34', '45']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Collector'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'configure'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'document'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Event'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'configure'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'collector_queue'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'collector'}
|
Create and run collector process for report data.
|
def _resolve_time(value):
if value is None or isinstance(value,(int,long)):
return value
if NUMBER_TIME.match(value):
return long(value)
simple = SIMPLE_TIME.match(value)
if SIMPLE_TIME.match(value):
multiplier = long( simple.groups()[0] )
constant = SIMPLE_TIMES[ simple.groups()[1] ]
return multiplier * constant
if value in GREGORIAN_TIMES:
return value
raise ValueError('Unsupported time format %s'%value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_resolve_time'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'block', 'children': ['6', '21', '34', '43', '80', '87']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '18']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '11'], 'value': 'or'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '15', 'type': 'tuple', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'long'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'NUMBER_TIME'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'long'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'simple'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'SIMPLE_TIME'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '43', 'type': 'if_statement', 'children': ['44', '50']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'SIMPLE_TIME'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '50', 'type': 'block', 'children': ['51', '64', '76']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'multiplier'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'long'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'subscript', 'children': ['58', '63']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'simple'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'constant'}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'SIMPLE_TIMES'}; {'id': '69', 'type': 'subscript', 'children': ['70', '75']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'simple'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '79'], 'value': '*'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'multiplier'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'constant'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '84']}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '83'], 'value': 'in'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'GREGORIAN_TIMES'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '87', 'type': 'raise_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '93'], 'value': '%'}; {'id': '92', 'type': 'string', 'children': [], 'value': "'Unsupported time format %s'"}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Resolve the time in seconds of a configuration value.
|
def fix_positions(self):
shift_x = 0
for m in self.__reactants:
max_x = self.__fix_positions(m, shift_x, 0)
shift_x = max_x + 1
arrow_min = shift_x
if self.__reagents:
for m in self.__reagents:
max_x = self.__fix_positions(m, shift_x, 1.5)
shift_x = max_x + 1
else:
shift_x += 3
arrow_max = shift_x - 1
for m in self.__products:
max_x = self.__fix_positions(m, shift_x, 0)
shift_x = max_x + 1
self._arrow = (arrow_min, arrow_max)
self.flush_cache()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fix_positions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '33', '37', '71', '77', '100', '108']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '15']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '__reactants'}; {'id': '15', 'type': 'block', 'children': ['16', '27']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'max_x'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '__fix_positions'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '32'], 'value': '+'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'max_x'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'arrow_min'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '41', '65']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '__reagents'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'for_statement', 'children': ['43', '44', '47']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '__reagents'}; {'id': '47', 'type': 'block', 'children': ['48', '59']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'max_x'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '__fix_positions'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57', '58']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '58', 'type': 'float', 'children': [], 'value': '1.5'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '+'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'max_x'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'else_clause', 'children': ['66']}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'augmented_assignment', 'children': ['69', '70'], 'value': '+='}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'arrow_max'}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '76'], 'value': '-'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'for_statement', 'children': ['78', '79', '82']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': '__products'}; {'id': '82', 'type': 'block', 'children': ['83', '94']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'max_x'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '__fix_positions'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92', '93']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'shift_x'}; {'id': '97', 'type': 'binary_operator', 'children': ['98', '99'], 'value': '+'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'max_x'}; {'id': '99', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_arrow'}; {'id': '105', 'type': 'tuple', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'arrow_min'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'arrow_max'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'flush_cache'}; {'id': '113', 'type': 'argument_list', 'children': []}
|
fix coordinates of molecules in reaction
|
def begin(self):
self._device.writeList(HT16K33_SYSTEM_SETUP | HT16K33_OSCILLATOR, [])
self.set_blink(HT16K33_BLINK_OFF)
self.set_brightness(15)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'begin'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '25']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_device'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'writeList'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '16'], 'value': '|'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'HT16K33_SYSTEM_SETUP'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'HT16K33_OSCILLATOR'}; {'id': '17', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'set_blink'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'HT16K33_BLINK_OFF'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'set_brightness'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'integer', 'children': [], 'value': '15'}
|
Initialize driver with LEDs enabled and all turned off.
|
def save(self):
self.cells = list(self.renumber())
if not self.cells[-1].endswith('\n'):
self.cells[-1] += '\n'
with open(self.filename, 'w') as file_open:
file_open.write('\n\n'.join(self.cells))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cells'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'renumber'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '32']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '30']}; {'id': '22', 'type': 'attribute', 'children': ['23', '29']}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cells'}; {'id': '27', 'type': 'unary_operator', 'children': ['28'], 'value': '-'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'augmented_assignment', 'children': ['35', '41'], 'value': '+='}; {'id': '35', 'type': 'subscript', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cells'}; {'id': '39', 'type': 'unary_operator', 'children': ['40'], 'value': '-'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '42', 'type': 'with_statement', 'children': ['43', '55']}; {'id': '43', 'type': 'with_clause', 'children': ['44']}; {'id': '44', 'type': 'with_item', 'children': ['45']}; {'id': '45', 'type': 'as_pattern', 'children': ['46', '53']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '53', 'type': 'as_pattern_target', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'file_open'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'file_open'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'\\n\\n'"}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'cells'}
|
Format and save cells.
|
def dropIndex(cls, fields) :
"removes an index created with ensureIndex "
con = RabaConnection(cls._raba_namespace)
rlf, ff = cls._parseIndex(fields)
for name in rlf :
con.dropIndex(name, 'anchor_raba_id')
con.dropIndex(cls.__name__, ff)
con.commit()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dropIndex'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '18', '29', '41', '51']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"removes an index created with ensureIndex "'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'RabaConnection'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_raba_namespace'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rlf'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_parseIndex'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'rlf'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'dropIndex'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'anchor_raba_id'"}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dropIndex'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'commit'}; {'id': '56', 'type': 'argument_list', 'children': []}
|
removes an index created with ensureIndex
|
def head(self, item):
uri = "/%s/%s" % (self.uri_base, utils.get_id(item))
return self._head(uri)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'head'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '6', 'type': 'block', 'children': ['7', '22']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'uri'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '12'], 'value': '%'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"/%s/%s"'}; {'id': '12', 'type': 'tuple', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'uri_base'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get_id'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_head'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'uri'}
|
Makes a HEAD request on a specific item.
|
def biopython_protein_scale(inseq, scale, custom_scale_dict=None, window=7):
if scale == 'kd_hydrophobicity':
scale_dict = kd_hydrophobicity_one
elif scale == 'bulkiness':
scale_dict = bulkiness_one
elif scale == 'custom':
scale_dict = custom_scale_dict
else:
raise ValueError('Scale not available')
inseq = ssbio.protein.sequence.utils.cast_to_str(inseq)
analysed_seq = ProteinAnalysis(inseq)
result = analysed_seq.protein_scale(param_dict=scale_dict, window=window)
for i in range(window // 2):
result.insert(0, float("Inf"))
result.append(float("Inf"))
return result
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'biopython_protein_scale'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'inseq'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'custom_scale_dict'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'window'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '12', 'type': 'block', 'children': ['13', '47', '62', '69', '83', '113']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17', '22', '31', '40']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': '=='}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'kd_hydrophobicity'"}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'scale_dict'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kd_hydrophobicity_one'}; {'id': '22', 'type': 'elif_clause', 'children': ['23', '26']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': '=='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'bulkiness'"}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'scale_dict'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'bulkiness_one'}; {'id': '31', 'type': 'elif_clause', 'children': ['32', '35']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': '=='}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'custom'"}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'scale_dict'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'custom_scale_dict'}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'raise_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'Scale not available'"}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'inseq'}; {'id': '50', 'type': 'call', 'children': ['51', '60']}; {'id': '51', 'type': 'attribute', 'children': ['52', '59']}; {'id': '52', 'type': 'attribute', 'children': ['53', '58']}; {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ssbio'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'protein'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'cast_to_str'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'inseq'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'analysed_seq'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'ProteinAnalysis'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'inseq'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'analysed_seq'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'protein_scale'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '80']}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'scale_dict'}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'window'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'window'}; {'id': '83', 'type': 'for_statement', 'children': ['84', '85', '91']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '//'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'window'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '91', 'type': 'block', 'children': ['92', '103']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '99']}; {'id': '98', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'string', 'children': [], 'value': '"Inf"'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'string', 'children': [], 'value': '"Inf"'}; {'id': '113', 'type': 'return_statement', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'result'}
|
Use Biopython to calculate properties using a sliding window over a sequence given a specific scale to use.
|
def _make_txn(signer, setting_key, payload):
serialized_payload = payload.SerializeToString()
header = TransactionHeader(
signer_public_key=signer.get_public_key().as_hex(),
family_name='sawtooth_settings',
family_version='1.0',
inputs=_config_inputs(setting_key),
outputs=_config_outputs(setting_key),
dependencies=[],
payload_sha512=hashlib.sha512(serialized_payload).hexdigest(),
batcher_public_key=signer.get_public_key().as_hex()
).SerializeToString()
return Transaction(
header=header,
header_signature=signer.sign(header),
payload=serialized_payload)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_txn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'signer'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'setting_key'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '81']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'serialized_payload'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'SerializeToString'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '19', 'type': 'call', 'children': ['20', '80']}; {'id': '20', 'type': 'attribute', 'children': ['21', '79']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'TransactionHeader'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '35', '38', '41', '47', '53', '56', '68']}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'signer_public_key'}; {'id': '26', 'type': 'call', 'children': ['27', '34']}; {'id': '27', 'type': 'attribute', 'children': ['28', '33']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'signer'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get_public_key'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'as_hex'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'family_name'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'sawtooth_settings'"}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'family_version'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'1.0'"}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_config_inputs'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'setting_key'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_config_outputs'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'setting_key'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dependencies'}; {'id': '55', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'payload_sha512'}; {'id': '58', 'type': 'call', 'children': ['59', '67']}; {'id': '59', 'type': 'attribute', 'children': ['60', '66']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'sha512'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'serialized_payload'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'hexdigest'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'batcher_public_key'}; {'id': '70', 'type': 'call', 'children': ['71', '78']}; {'id': '71', 'type': 'attribute', 'children': ['72', '77']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'signer'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'get_public_key'}; {'id': '76', 'type': 'argument_list', 'children': []}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'as_hex'}; {'id': '78', 'type': 'argument_list', 'children': []}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'SerializeToString'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'id': '81', 'type': 'return_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Transaction'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '88', '96']}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '88', 'type': 'keyword_argument', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'header_signature'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'signer'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'sign'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '96', 'type': 'keyword_argument', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'serialized_payload'}
|
Creates and signs a sawtooth_settings transaction with with a payload.
|
def _traverse_command(self, name, *args, **kwargs):
if not name in self.available_commands:
raise AttributeError("%s is not an available command for %s" %
(name, self.__class__.__name__))
attr = getattr(self.connection, "%s" % name)
key = self.key
log.debug(u"Requesting %s with key %s and args %s" % (name, key, args))
result = attr(key, *args, **kwargs)
result = self.post_command(
sender=self,
name=name,
result=result,
args=args,
kwargs=kwargs
)
return result
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_traverse_command'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '32', '44', '50', '62', '73', '96']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '18']}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'in'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'available_commands'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'raise_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '%'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"%s is not an available command for %s"'}; {'id': '25', 'type': 'tuple', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '%'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"%s"'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '%'}; {'id': '57', 'type': 'string', 'children': [], 'value': 'u"Requesting %s with key %s and args %s"'}; {'id': '58', 'type': 'tuple', 'children': ['59', '60', '61']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '71']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '69', 'type': 'list_splat', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '71', 'type': 'dictionary_splat', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'post_command'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '84', '87', '90', '93']}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'sender'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'result'}
|
Add the key to the args and call the Redis command.
|
def ensure_stacker_compat_config(config_filename):
try:
with open(config_filename, 'r') as stream:
yaml.safe_load(stream)
except yaml.constructor.ConstructorError as yaml_error:
if yaml_error.problem.startswith(
'could not determine a constructor for the tag \'!'):
LOGGER.error('"%s" appears to be a CloudFormation template, '
'but is located in the top level of a module '
'alongside the CloudFormation config files (i.e. '
'the file or files indicating the stack names & '
'parameters). Please move the template to a '
'subdirectory.',
config_filename)
sys.exit(1)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ensure_stacker_compat_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config_filename'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '27']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'with_statement', 'children': ['9', '19']}; {'id': '9', 'type': 'with_clause', 'children': ['10']}; {'id': '10', 'type': 'with_item', 'children': ['11']}; {'id': '11', 'type': 'as_pattern', 'children': ['12', '17']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'config_filename'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '17', 'type': 'as_pattern_target', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'safe_load'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '27', 'type': 'except_clause', 'children': ['28', '36']}; {'id': '28', 'type': 'as_pattern', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'constructor'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ConstructorError'}; {'id': '34', 'type': 'as_pattern_target', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'yaml_error'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '46']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'yaml_error'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'problem'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'could not determine a constructor for the tag \\'!'"}; {'id': '46', 'type': 'block', 'children': ['47', '61']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '60']}; {'id': '53', 'type': 'concatenated_string', 'children': ['54', '55', '56', '57', '58', '59']}; {'id': '54', 'type': 'string', 'children': [], 'value': '\'"%s" appears to be a CloudFormation template, \''}; {'id': '55', 'type': 'string', 'children': [], 'value': "'but is located in the top level of a module '"}; {'id': '56', 'type': 'string', 'children': [], 'value': "'alongside the CloudFormation config files (i.e. '"}; {'id': '57', 'type': 'string', 'children': [], 'value': "'the file or files indicating the stack names & '"}; {'id': '58', 'type': 'string', 'children': [], 'value': "'parameters). Please move the template to a '"}; {'id': '59', 'type': 'string', 'children': [], 'value': "'subdirectory.'"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'config_filename'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}
|
Ensure config file can be loaded by Stacker.
|
def checksum_contracts(self) -> None:
checksums: Dict[str, str] = {}
for contracts_dir in self.contracts_source_dirs.values():
file: Path
for file in contracts_dir.glob('*.sol'):
checksums[file.name] = hashlib.sha256(file.read_bytes()).hexdigest()
self.overall_checksum = hashlib.sha256(
':'.join(checksums[key] for key in sorted(checksums)).encode(),
).hexdigest()
self.contracts_checksums = checksums
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'checksum_contracts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '20', '65', '97']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11', '19']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'checksums'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'generic_type', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Dict'}; {'id': '14', 'type': 'type_parameter', 'children': ['15', '17']}; {'id': '15', 'type': 'type', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '17', 'type': 'type', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '19', 'type': 'dictionary', 'children': []}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '29']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'contracts_dir'}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'contracts_source_dirs'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30', '35']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '33', 'type': 'type', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '43']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'contracts_dir'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'*.sol'"}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '51']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'checksums'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '51', 'type': 'call', 'children': ['52', '64']}; {'id': '52', 'type': 'attribute', 'children': ['53', '63']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sha256'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'read_bytes'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'hexdigest'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'overall_checksum'}; {'id': '70', 'type': 'call', 'children': ['71', '96']}; {'id': '71', 'type': 'attribute', 'children': ['72', '95']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'sha256'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '94']}; {'id': '78', 'type': 'attribute', 'children': ['79', '93']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '83', 'type': 'generator_expression', 'children': ['84', '87']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'checksums'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '87', 'type': 'for_in_clause', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'checksums'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '94', 'type': 'argument_list', 'children': []}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'hexdigest'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'contracts_checksums'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'checksums'}
|
Remember the checksum of each source, and the overall checksum.
|
def _create_plain_field(self, attr, options):
method = self._get_field_method(attr.py_type) or self._create_other_field
klass, options = method(attr, options)
if attr.is_unique:
options['validators'].append(validators.UniqueEntityValidator(attr.entity))
return klass, options
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_plain_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '7', 'type': 'block', 'children': ['8', '23', '33', '54']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '20'], 'value': 'or'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_get_field_method'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'py_type'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_create_other_field'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'pattern_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'is_unique'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'validators'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'validators'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'UniqueEntityValidator'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'expression_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'options'}
|
Creates the form element.
|
def update(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '12', '17']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Creates or updates a property for the instance for each parameter.
|
def install_supervisor(self, update=False):
script = supervisor.Recipe(
self.buildout,
self.name,
{'user': self.options.get('user'),
'program': self.options.get('program'),
'command': templ_cmd.render(config=self.conf_filename, prefix=self.prefix),
'stopwaitsecs': '30',
'killasgroup': 'true',
})
return script.install(update)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_supervisor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '67']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'supervisor'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Recipe'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20', '23']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'buildout'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'dictionary', 'children': ['24', '34', '44', '61', '64']}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'program'"}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'program'"}; {'id': '44', 'type': 'pair', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'command'"}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'templ_cmd'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '56']}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'conf_filename'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '61', 'type': 'pair', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'stopwaitsecs'"}; {'id': '63', 'type': 'string', 'children': [], 'value': "'30'"}; {'id': '64', 'type': 'pair', 'children': ['65', '66']}; {'id': '65', 'type': 'string', 'children': [], 'value': "'killasgroup'"}; {'id': '66', 'type': 'string', 'children': [], 'value': "'true'"}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'install'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'update'}
|
install supervisor config for redis
|
def _get_results_from_api(identifiers, endpoints, api_key, api_secret):
if api_key is not None and api_secret is not None:
client = housecanary.ApiClient(api_key, api_secret)
else:
client = housecanary.ApiClient()
wrapper = getattr(client, endpoints[0].split('/')[0])
if len(endpoints) > 1:
return wrapper.component_mget(identifiers, endpoints)
else:
return wrapper.fetch_identifier_component(endpoints[0], identifiers)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_results_from_api'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'identifiers'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'api_key'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'api_secret'}; {'id': '8', 'type': 'block', 'children': ['9', '38', '55']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '17', '28']}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '14'], 'value': 'and'}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is not'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'api_key'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'is not'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'api_secret'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'housecanary'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ApiClient'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'api_key'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'api_secret'}; {'id': '28', 'type': 'else_clause', 'children': ['29']}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'housecanary'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ApiClient'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'wrapper'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '45', 'type': 'subscript', 'children': ['46', '54']}; {'id': '46', 'type': 'call', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '54', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '62', '71']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '61'], 'value': '>'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'wrapper'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'component_mget'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'identifiers'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '71', 'type': 'else_clause', 'children': ['72']}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'wrapper'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'fetch_identifier_component'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '82']}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'identifiers'}
|
Use the HouseCanary API Python Client to access the API
|
def _dmi_cast(key, val, clean=True):
if clean and not _dmi_isclean(key, val):
return
elif not re.match(r'serial|part|asset|product', key, flags=re.IGNORECASE):
if ',' in val:
val = [el.strip() for el in val.split(',')]
else:
try:
val = int(val)
except Exception:
pass
return val
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_dmi_cast'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'clean'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '73']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '19', '21']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '13'], 'value': 'and'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'clean'}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_dmi_isclean'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': []}; {'id': '21', 'type': 'elif_clause', 'children': ['22', '35']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'string', 'children': [], 'value': "r'serial|part|asset|product'"}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'IGNORECASE'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40', '58']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'in'}; {'id': '38', 'type': 'string', 'children': [], 'value': "','"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '44', 'type': 'list_comprehension', 'children': ['45', '50']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'for_in_clause', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': "','"}; {'id': '58', 'type': 'else_clause', 'children': ['59']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'try_statement', 'children': ['61', '69']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '69', 'type': 'except_clause', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'pass_statement', 'children': []}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'val'}
|
Simple caster thingy for trying to fish out at least ints & lists from strings
|
def extract_pls_rsp(rsp_str):
try:
rsp = json.loads(rsp_str)
except ValueError:
traceback.print_exc()
err = sys.exc_info()[1]
err_str = ERROR_STR_PREFIX + str(err)
return RET_ERROR, err_str, None
error_code = int(rsp['retType'])
if error_code != 1:
error_str = ERROR_STR_PREFIX + rsp['retMsg']
return RET_ERROR, error_str, None
return RET_OK, "", rsp
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_pls_rsp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'rsp_str'}; {'id': '5', 'type': 'block', 'children': ['6', '50', '59', '77']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '17']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'rsp'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'rsp_str'}; {'id': '17', 'type': 'except_clause', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '19', 'type': 'block', 'children': ['20', '26', '36', '45']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'print_exc'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '29', 'type': 'subscript', 'children': ['30', '35']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'exc_info'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'err_str'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '+'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ERROR_STR_PREFIX'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'expression_list', 'children': ['47', '48', '49']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'RET_ERROR'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'err_str'}; {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'error_code'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'rsp'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'retType'"}; {'id': '59', 'type': 'if_statement', 'children': ['60', '63']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': '!='}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'error_code'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '63', 'type': 'block', 'children': ['64', '72']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'error_str'}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '69'], 'value': '+'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ERROR_STR_PREFIX'}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'rsp'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'retMsg'"}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'expression_list', 'children': ['74', '75', '76']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'RET_ERROR'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'error_str'}; {'id': '76', 'type': 'None', 'children': []}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'expression_list', 'children': ['79', '80', '81']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'RET_OK'}; {'id': '80', 'type': 'string', 'children': [], 'value': '""'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'rsp'}
|
Extract the response of PLS
|
def export_to_dom(self):
namespaces = 'xmlns="http://www.neuroml.org/lems/%s" ' + \
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + \
'xsi:schemaLocation="http://www.neuroml.org/lems/%s %s"'
namespaces = namespaces%(self.target_lems_version,self.target_lems_version,self.schema_location)
xmlstr = '<Lems %s>'%namespaces
for include in self.includes:
xmlstr += include.toxml()
for target in self.targets:
xmlstr += '<Target component="{0}"/>'.format(target)
for dimension in self.dimensions:
xmlstr += dimension.toxml()
for unit in self.units:
xmlstr += unit.toxml()
for constant in self.constants:
xmlstr += constant.toxml()
for component_type in self.component_types:
xmlstr += component_type.toxml()
for component in self.components:
xmlstr += component.toxml()
xmlstr += '</Lems>'
xmldom = minidom.parseString(xmlstr)
return xmldom
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_to_dom'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '29', '35', '49', '64', '78', '92', '106', '120', '134', '138', '147']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '13'], 'value': '+'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '12'], 'value': '+'}; {'id': '11', 'type': 'string', 'children': [], 'value': '\'xmlns="http://www.neuroml.org/lems/%s" \''}; {'id': '12', 'type': 'string', 'children': [], 'value': '\'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \''}; {'id': '13', 'type': 'string', 'children': [], 'value': '\'xsi:schemaLocation="http://www.neuroml.org/lems/%s %s"\''}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '19'], 'value': '%'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '19', 'type': 'tuple', 'children': ['20', '23', '26']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'target_lems_version'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'target_lems_version'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'schema_location'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '%'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'<Lems %s>'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '40']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'include'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'includes'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'augmented_assignment', 'children': ['43', '44'], 'value': '+='}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'include'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'toxml'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '54']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'augmented_assignment', 'children': ['57', '58'], 'value': '+='}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': '\'<Target component="{0}"/>\''}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '64', 'type': 'for_statement', 'children': ['65', '66', '69']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'dimension'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'dimensions'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'augmented_assignment', 'children': ['72', '73'], 'value': '+='}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'dimension'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'toxml'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'for_statement', 'children': ['79', '80', '83']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'augmented_assignment', 'children': ['86', '87'], 'value': '+='}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'toxml'}; {'id': '91', 'type': 'argument_list', 'children': []}; {'id': '92', 'type': 'for_statement', 'children': ['93', '94', '97']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'constant'}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'constants'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'augmented_assignment', 'children': ['100', '101'], 'value': '+='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'constant'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'toxml'}; {'id': '105', 'type': 'argument_list', 'children': []}; {'id': '106', 'type': 'for_statement', 'children': ['107', '108', '111']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'component_type'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'component_types'}; {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'augmented_assignment', 'children': ['114', '115'], 'value': '+='}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'component_type'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'toxml'}; {'id': '119', 'type': 'argument_list', 'children': []}; {'id': '120', 'type': 'for_statement', 'children': ['121', '122', '125']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'components'}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'augmented_assignment', 'children': ['128', '129'], 'value': '+='}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'toxml'}; {'id': '133', 'type': 'argument_list', 'children': []}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'augmented_assignment', 'children': ['136', '137'], 'value': '+='}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '137', 'type': 'string', 'children': [], 'value': "'</Lems>'"}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'xmldom'}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'minidom'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'parseString'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'xmlstr'}; {'id': '147', 'type': 'return_statement', 'children': ['148']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'xmldom'}
|
Exports this model to a DOM.
|
def execute(self):
self.autocomplete()
if len(self.argv):
cmd = self.argv[0]
cmd_argv = self.get_argv_for_command()
self.run_command(cmd, cmd_argv)
else:
self.show_help()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'autocomplete'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'if_statement', 'children': ['13', '19', '44']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '19', 'type': 'block', 'children': ['20', '28', '36']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cmd_argv'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get_argv_for_command'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'run_command'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cmd_argv'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'show_help'}; {'id': '51', 'type': 'argument_list', 'children': []}
|
Executes whole process of parsing and running command.
|
def _handleSmsStatusReport(self, notificationLine):
self.log.debug('SMS status report received')
cdsiMatch = self.CDSI_REGEX.match(notificationLine)
if cdsiMatch:
msgMemory = cdsiMatch.group(1)
msgIndex = cdsiMatch.group(2)
report = self.readStoredSms(msgIndex, msgMemory)
self.deleteStoredSms(msgIndex)
if report.reference in self.sentSms:
self.sentSms[report.reference].report = report
if self._smsStatusReportEvent:
self._smsStatusReportEvent.set()
else:
self.smsStatusReportCallback(report)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_handleSmsStatusReport'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'notificationLine'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '27']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'SMS status report received'"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cdsiMatch'}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'CDSI_REGEX'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'notificationLine'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cdsiMatch'}; {'id': '29', 'type': 'block', 'children': ['30', '39', '48', '58', '65', '86']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'msgMemory'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cdsiMatch'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'msgIndex'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cdsiMatch'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'readStoredSms'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'msgIndex'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'msgMemory'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'deleteStoredSms'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'msgIndex'}; {'id': '65', 'type': 'if_statement', 'children': ['66', '73']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '70'], 'value': 'in'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'reference'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'sentSms'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '85']}; {'id': '76', 'type': 'attribute', 'children': ['77', '84']}; {'id': '77', 'type': 'subscript', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'sentSms'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'reference'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '86', 'type': 'if_statement', 'children': ['87', '90', '99']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_smsStatusReportEvent'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '98']}; {'id': '93', 'type': 'attribute', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': '_smsStatusReportEvent'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '98', 'type': 'argument_list', 'children': []}; {'id': '99', 'type': 'else_clause', 'children': ['100']}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'smsStatusReportCallback'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'report'}
|
Handler for SMS status reports
|
def flush(self):
self._check_open_file()
if self.allow_update and not self.is_stream:
contents = self._io.getvalue()
if self._append:
self._sync_io()
old_contents = (self.file_object.byte_contents
if is_byte_string(contents) else
self.file_object.contents)
contents = old_contents + contents[self._flush_pos:]
self._set_stream_contents(contents)
self.update_flush_pos()
else:
self._io.flush()
if self.file_object.set_contents(contents, self._encoding):
if self._filesystem.is_windows_fs:
self._changed = True
else:
current_time = time.time()
self.file_object.st_ctime = current_time
self.file_object.st_mtime = current_time
self._file_epoch = self.file_object.epoch
if not self.is_stream:
self._flush_related_files()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flush'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_check_open_file'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'if_statement', 'children': ['13', '21']}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '17'], 'value': 'and'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'allow_update'}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'is_stream'}; {'id': '21', 'type': 'block', 'children': ['22', '32', '97', '149', '159']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_io'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'getvalue'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36', '87']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_append'}; {'id': '36', 'type': 'block', 'children': ['37', '43', '62', '74', '81']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_sync_io'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'old_contents'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'conditional_expression', 'children': ['48', '53', '57'], 'value': 'if'}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'file_object'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'byte_contents'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'is_byte_string'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'file_object'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '+'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'old_contents'}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '69', 'type': 'slice', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_flush_pos'}; {'id': '73', 'type': 'colon', 'children': []}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_set_stream_contents'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'update_flush_pos'}; {'id': '86', 'type': 'argument_list', 'children': []}; {'id': '87', 'type': 'else_clause', 'children': ['88']}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '96']}; {'id': '91', 'type': 'attribute', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_io'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'id': '97', 'type': 'if_statement', 'children': ['98', '109']}; {'id': '98', 'type': 'call', 'children': ['99', '104']}; {'id': '99', 'type': 'attribute', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'file_object'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'set_contents'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '_encoding'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'if_statement', 'children': ['111', '116', '123']}; {'id': '111', 'type': 'attribute', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_filesystem'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'is_windows_fs'}; {'id': '116', 'type': 'block', 'children': ['117']}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': '_changed'}; {'id': '122', 'type': 'True', 'children': []}; {'id': '123', 'type': 'else_clause', 'children': ['124']}; {'id': '124', 'type': 'block', 'children': ['125', '133', '141']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'assignment', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'current_time'}; {'id': '128', 'type': 'call', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '132', 'type': 'argument_list', 'children': []}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '140']}; {'id': '135', 'type': 'attribute', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'file_object'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'st_ctime'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'current_time'}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '148']}; {'id': '143', 'type': 'attribute', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'file_object'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'st_mtime'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'current_time'}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': '_file_epoch'}; {'id': '154', 'type': 'attribute', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'file_object'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'epoch'}; {'id': '159', 'type': 'if_statement', 'children': ['160', '164']}; {'id': '160', 'type': 'not_operator', 'children': ['161']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'is_stream'}; {'id': '164', 'type': 'block', 'children': ['165']}; {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'call', 'children': ['167', '170']}; {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': '_flush_related_files'}; {'id': '170', 'type': 'argument_list', 'children': []}
|
Flush file contents to 'disk'.
|
def dictionary_validator(key_type, value_type):
def _validate_dictionary(instance, attribute, value):
if not isinstance(value, dict):
raise TypeError('"{}" must be a dictionary'.format(attribute.name))
for key, data in value.items():
if not isinstance(key, key_type):
raise TypeError(
'"{name}" dictionary keys must be of type "{type}"'.format(name=attribute.name, type=key_type)
)
if not isinstance(data, value_type):
raise TypeError(
'"{name}" dictionary values must be of type "{type}"'.format(name=attribute.name, type=value_type)
)
return _validate_dictionary
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dictionary_validator'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value_type'}; {'id': '6', 'type': 'block', 'children': ['7', '94']}; {'id': '7', 'type': 'function_definition', 'children': ['8', '9', '13']}; {'id': '8', 'type': 'function_name', 'children': [], 'value': '_validate_dictionary'}; {'id': '9', 'type': 'parameters', 'children': ['10', '11', '12']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'block', 'children': ['14', '34']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '21']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '\'"{}" must be a dictionary\''}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '34', 'type': 'for_statement', 'children': ['35', '38', '43']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'block', 'children': ['44', '69']}; {'id': '44', 'type': 'if_statement', 'children': ['45', '51']}; {'id': '45', 'type': 'not_operator', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'raise_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': '\'"{name}" dictionary keys must be of type "{type}"\''}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '66']}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '69', 'type': 'if_statement', 'children': ['70', '76']}; {'id': '70', 'type': 'not_operator', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'value_type'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'raise_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'string', 'children': [], 'value': '\'"{name}" dictionary values must be of type "{type}"\''}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '91']}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'value_type'}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '_validate_dictionary'}
|
Validator for ``attrs`` that performs deep type checking of dictionaries.
|
def _dispatch_event(self, event: LutronEvent, params: Dict):
for handler, context in self._subscribers:
handler(self, context, event, params)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_dispatch_event'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'LutronEvent'}; {'id': '9', 'type': 'typed_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Dict'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'for_statement', 'children': ['15', '18', '21']}; {'id': '15', 'type': 'pattern_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_subscribers'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '28', '29']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'params'}
|
Dispatches the specified event to all the subscribers.
|
def _py_expand_short(subsequence, sequence, max_l_dist):
subseq_len = len(subsequence)
if subseq_len == 0:
return (0, 0)
scores = list(range(1, subseq_len + 1))
min_score = subseq_len
min_score_idx = -1
for seq_index, char in enumerate(sequence):
a = seq_index
c = a + 1
for subseq_index in range(subseq_len):
b = scores[subseq_index]
c = scores[subseq_index] = min(
a + (char != subsequence[subseq_index]),
b + 1,
c + 1,
)
a = b
if c <= min_score:
min_score = c
min_score_idx = seq_index
elif min(scores) >= min_score:
break
return (min_score, min_score_idx + 1) if min_score <= max_l_dist else (None, None)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_py_expand_short'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'subsequence'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'max_l_dist'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '24', '37', '41', '46', '128']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'subseq_len'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'subsequence'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '=='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'subseq_len'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'tuple', 'children': ['22', '23']}; {'id': '22', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '+'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'subseq_len'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'min_score'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'subseq_len'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'min_score_idx'}; {'id': '44', 'type': 'unary_operator', 'children': ['45'], 'value': '-'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'for_statement', 'children': ['47', '50', '54']}; {'id': '47', 'type': 'pattern_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'seq_index'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '54', 'type': 'block', 'children': ['55', '59', '65', '106']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'seq_index'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '+'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'for_statement', 'children': ['66', '67', '71']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'subseq_index'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'subseq_len'}; {'id': '71', 'type': 'block', 'children': ['72', '78', '102']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'subseq_index'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '81', 'type': 'assignment', 'children': ['82', '85']}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'subseq_index'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '96', '99']}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '+'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '90', 'type': '()', 'children': ['91']}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': '!='}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '93', 'type': 'subscript', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'subsequence'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'subseq_index'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '98'], 'value': '+'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '+'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '106', 'type': 'if_statement', 'children': ['107', '110', '119']}; {'id': '107', 'type': 'comparison_operator', 'children': ['108', '109'], 'value': '<='}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'min_score'}; {'id': '110', 'type': 'block', 'children': ['111', '115']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'min_score'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'min_score_idx'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'seq_index'}; {'id': '119', 'type': 'elif_clause', 'children': ['120', '126']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '125'], 'value': '>='}; {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'min_score'}; {'id': '126', 'type': 'block', 'children': ['127']}; {'id': '127', 'type': 'break_statement', 'children': []}; {'id': '128', 'type': 'return_statement', 'children': ['129']}; {'id': '129', 'type': 'conditional_expression', 'children': ['130', '135', '138'], 'value': 'if'}; {'id': '130', 'type': 'tuple', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'min_score'}; {'id': '132', 'type': 'binary_operator', 'children': ['133', '134'], 'value': '+'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'min_score_idx'}; {'id': '134', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '135', 'type': 'comparison_operator', 'children': ['136', '137'], 'value': '<='}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'min_score'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'max_l_dist'}; {'id': '138', 'type': 'tuple', 'children': ['139', '140']}; {'id': '139', 'type': 'None', 'children': []}; {'id': '140', 'type': 'None', 'children': []}
|
Straightforward implementation of partial match expansion.
|
def _to_dict(self):
physical_prop_names = find_PhysicalProperty(self)
physical_prop_vals = [getattr(self, prop) for prop in physical_prop_names]
return dict(zip(physical_prop_names, physical_prop_vals))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '25']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'physical_prop_names'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'find_PhysicalProperty'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'physical_prop_vals'}; {'id': '16', 'type': 'list_comprehension', 'children': ['17', '22']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'physical_prop_names'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'physical_prop_names'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'physical_prop_vals'}
|
Return a dictionary representation of the current object.
|
def diffuse_template(self, **kwargs):
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.diffuse_template_format.format(**kwargs_copy)
if kwargs.get('fullpath', False):
return self.fullpath(localpath=localpath)
return localpath
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diffuse_template'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '26', '33', '45', '63']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'base_dict'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'dictionary_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_replace_none'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'localpath'}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'NameFactory'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'diffuse_template_format'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'dictionary_splat', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '53']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'fullpath'"}; {'id': '52', 'type': 'False', 'children': []}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'fullpath'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'localpath'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'localpath'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'localpath'}
|
return the file name for other diffuse map templates
|
def theme_static_with_version(ctx, filename, external=False):
if current_app.theme_manager.static_folder:
url = assets.cdn_for('_themes.static',
filename=current.identifier + '/' + filename,
_external=external)
else:
url = assets.cdn_for('_themes.static',
themeid=current.identifier,
filename=filename,
_external=external)
if url.endswith('/'):
return url
if current_app.config['DEBUG']:
burst = time()
else:
burst = current.entrypoint.dist.version
return '{url}?_={burst}'.format(url=url, burst=burst)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'theme_static_with_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '60', '70', '95']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '16', '38']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'theme_manager'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'static_folder'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'assets'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cdn_for'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '35']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'_themes.static'"}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '34'], 'value': '+'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '33'], 'value': '+'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_external'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'assets'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'cdn_for'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49', '54', '57']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'_themes.static'"}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'themeid'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_external'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'external'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '67']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '76', '83']}; {'id': '71', 'type': 'subscript', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'DEBUG'"}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'burst'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '82', 'type': 'argument_list', 'children': []}; {'id': '83', 'type': 'else_clause', 'children': ['84']}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'burst'}; {'id': '88', 'type': 'attribute', 'children': ['89', '94']}; {'id': '89', 'type': 'attribute', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'entrypoint'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'{url}?_={burst}'"}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '104']}; {'id': '101', 'type': 'keyword_argument', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'burst'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'burst'}
|
Override the default theme static to add cache burst
|
def strip(notebook):
for cell in notebook.cells:
if cell.cell_type == 'code':
cell.outputs = []
cell.execution_count = None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'strip'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cells'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': '=='}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cell_type'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'code'"}; {'id': '18', 'type': 'block', 'children': ['19', '25']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'execution_count'}; {'id': '30', 'type': 'None', 'children': []}
|
Remove outputs from a notebook.
|
def _is_mobile(ntype):
return (ntype == PhoneNumberType.MOBILE or
ntype == PhoneNumberType.FIXED_LINE_OR_MOBILE or
ntype == PhoneNumberType.PAGER)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_mobile'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ntype'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': '()', 'children': ['8']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '20'], 'value': 'or'}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '15'], 'value': 'or'}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': '=='}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ntype'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'MOBILE'}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '=='}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ntype'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'FIXED_LINE_OR_MOBILE'}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': '=='}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ntype'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'PAGER'}
|
Checks if the supplied number type supports carrier lookup
|
def install():
tmp_weboob_dir = '/tmp/weboob'
while (os.path.exists(tmp_weboob_dir)):
tmp_weboob_dir += '1'
print 'Fetching sources in temporary dir {}'.format(tmp_weboob_dir)
result = cmd_exec('git clone {} {}'.format(WEBOOB_REPO, tmp_weboob_dir))
if (result['error']):
print result['stderr']
print 'Weboob installation failed: could not clone repository'
exit()
print 'Sources fetched, will now process to installation'
result = cmd_exec('cd {} && ./setup.py install'.format(tmp_weboob_dir))
shutil.rmtree(tmp_weboob_dir)
if (result['error']):
print result['stderr']
print 'Weboob installation failed: setup failed'
exit()
print result['stdout']
weboob_version = get_weboob_version()
if (not weboob_version):
print 'Weboob installation failed: version not detected'
exit()
print 'Weboob (version: {}) installation succeeded'.format(weboob_version)
update()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '24', '31', '44', '60', '62', '74', '81', '97', '101', '107', '118', '125']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'tmp_weboob_dir'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'/tmp/weboob'"}; {'id': '9', 'type': 'while_statement', 'children': ['10', '19']}; {'id': '10', 'type': '()', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tmp_weboob_dir'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'augmented_assignment', 'children': ['22', '23'], 'value': '+='}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tmp_weboob_dir'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'1'"}; {'id': '24', 'type': 'print_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'Fetching sources in temporary dir {}'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'tmp_weboob_dir'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cmd_exec'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'git clone {} {}'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'WEBOOB_REPO'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'tmp_weboob_dir'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '49']}; {'id': '45', 'type': '()', 'children': ['46']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '49', 'type': 'block', 'children': ['50', '54', '56']}; {'id': '50', 'type': 'print_statement', 'children': ['51']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'stderr'"}; {'id': '54', 'type': 'print_statement', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'Weboob installation failed: could not clone repository'"}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'print_statement', 'children': ['61']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'Sources fetched, will now process to installation'"}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'cmd_exec'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'cd {} && ./setup.py install'"}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'tmp_weboob_dir'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'shutil'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'rmtree'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'tmp_weboob_dir'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '86']}; {'id': '82', 'type': '()', 'children': ['83']}; {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '86', 'type': 'block', 'children': ['87', '91', '93']}; {'id': '87', 'type': 'print_statement', 'children': ['88']}; {'id': '88', 'type': 'subscript', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '90', 'type': 'string', 'children': [], 'value': "'stderr'"}; {'id': '91', 'type': 'print_statement', 'children': ['92']}; {'id': '92', 'type': 'string', 'children': [], 'value': "'Weboob installation failed: setup failed'"}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'id': '97', 'type': 'print_statement', 'children': ['98']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '100', 'type': 'string', 'children': [], 'value': "'stdout'"}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'weboob_version'}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'get_weboob_version'}; {'id': '106', 'type': 'argument_list', 'children': []}; {'id': '107', 'type': 'if_statement', 'children': ['108', '111']}; {'id': '108', 'type': '()', 'children': ['109']}; {'id': '109', 'type': 'not_operator', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'weboob_version'}; {'id': '111', 'type': 'block', 'children': ['112', '114']}; {'id': '112', 'type': 'print_statement', 'children': ['113']}; {'id': '113', 'type': 'string', 'children': [], 'value': "'Weboob installation failed: version not detected'"}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '117', 'type': 'argument_list', 'children': []}; {'id': '118', 'type': 'print_statement', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': "'Weboob (version: {}) installation succeeded'"}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'weboob_version'}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '128', 'type': 'argument_list', 'children': []}
|
Install weboob system-wide
|
def create(self, id):
resp = self.client.accounts.create(id=id)
self.display(resp)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'block', 'children': ['7', '22']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '10', 'type': 'call', 'children': ['11', '18']}; {'id': '11', 'type': 'attribute', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'accounts'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'resp'}
|
Create a new tenant id
|
def fromTFExample(bytestr):
example = tf.train.Example()
example.ParseFromString(bytestr)
return example
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fromTFExample'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'bytestr'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'train'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Example'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ParseFromString'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'bytestr'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'example'}
|
Deserializes a TFExample from a byte string
|
def schema_map(schema):
mapper = {}
for name in getFieldNames(schema):
mapper[name] = name
return mapper
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schema_map'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'mapper'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '16']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'getFieldNames'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'mapper'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'mapper'}
|
Return a valid ICachedItemMapper.map for schema
|
def _write_to_graph(self):
traces = []
for byte_code, trace_data in self.coverage.items():
traces += [list(trace_data.keys()), list(trace_data.values()), "r--"]
plt.plot(*traces)
plt.axis([0, self.end - self.begin, 0, 100])
plt.xlabel("Duration (seconds)")
plt.ylabel("Coverage (percentage)")
plt.savefig("{}.png".format(self.name))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write_to_graph'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '43', '51', '68', '75', '82']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'traces'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '14', '21']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'byte_code'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'trace_data'}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'coverage'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'augmented_assignment', 'children': ['24', '25'], 'value': '+='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'traces'}; {'id': '25', 'type': 'list', 'children': ['26', '34', '42'], 'value': '[list(trace_data.keys()), list(trace_data.values()), "r--"]'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'trace_data'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'trace_data'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'string', 'children': [], 'value': '"r--"'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'plt'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'list_splat', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'traces'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'plt'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'list', 'children': ['58', '59', '66', '67'], 'value': '[0, self.end - self.begin, 0, 100]'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '63'], 'value': '-'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'begin'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'plt'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'xlabel'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"Duration (seconds)"'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'plt'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ylabel'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'string', 'children': [], 'value': '"Coverage (percentage)"'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'plt'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'savefig'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': '"{}.png"'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Write the coverage results to a graph
|
def _clean_result(self, text):
text = re.sub('\s\s+', ' ', text)
text = re.sub('\.\.+', '.', text)
text = text.replace("'", "\\'")
return text
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_clean_result'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '29', '39']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '17']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'\\s\\s+'"}; {'id': '16', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '28']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'\\.\\.+'"}; {'id': '27', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"\'"'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"\\\\\'"'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'text'}
|
Remove double spaces, punctuation and escapes apostrophes.
|
def _question_line(self, section):
token = self.tok.get(want_leading = True)
if not token.is_whitespace():
self.last_name = dns.name.from_text(token.value, None)
name = self.last_name
token = self.tok.get()
if not token.is_identifier():
raise dns.exception.SyntaxError
try:
rdclass = dns.rdataclass.from_text(token.value)
token = self.tok.get()
if not token.is_identifier():
raise dns.exception.SyntaxError
except dns.exception.SyntaxError:
raise dns.exception.SyntaxError
except Exception:
rdclass = dns.rdataclass.IN
rdtype = dns.rdatatype.from_text(token.value)
self.message.find_rrset(self.message.question, name,
rdclass, rdtype, create=True,
force_unique=True)
if self.updating:
self.zone_rdclass = rdclass
self.tok.get_eol()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_question_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '44', '50', '60', '74', '137', '150', '172', '183']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tok'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'want_leading'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'if_statement', 'children': ['21', '27']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'is_whitespace'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'last_name'}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'from_text'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '43', 'type': 'None', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'last_name'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'tok'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'if_statement', 'children': ['61', '67']}; {'id': '61', 'type': 'not_operator', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'is_identifier'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'raise_statement', 'children': ['69']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'SyntaxError'}; {'id': '74', 'type': 'try_statement', 'children': ['75', '113', '126']}; {'id': '75', 'type': 'block', 'children': ['76', '89', '99']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'rdclass'}; {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'rdataclass'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'from_text'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '92', 'type': 'call', 'children': ['93', '98']}; {'id': '93', 'type': 'attribute', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'tok'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '98', 'type': 'argument_list', 'children': []}; {'id': '99', 'type': 'if_statement', 'children': ['100', '106']}; {'id': '100', 'type': 'not_operator', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'is_identifier'}; {'id': '105', 'type': 'argument_list', 'children': []}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'raise_statement', 'children': ['108']}; {'id': '108', 'type': 'attribute', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'SyntaxError'}; {'id': '113', 'type': 'except_clause', 'children': ['114', '119']}; {'id': '114', 'type': 'attribute', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'SyntaxError'}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'raise_statement', 'children': ['121']}; {'id': '121', 'type': 'attribute', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'SyntaxError'}; {'id': '126', 'type': 'except_clause', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '128', 'type': 'block', 'children': ['129']}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'rdclass'}; {'id': '132', 'type': 'attribute', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'rdataclass'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'IN'}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'assignment', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'rdtype'}; {'id': '140', 'type': 'call', 'children': ['141', '146']}; {'id': '141', 'type': 'attribute', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'dns'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'rdatatype'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'from_text'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}; {'id': '151', 'type': 'call', 'children': ['152', '157']}; {'id': '152', 'type': 'attribute', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'find_rrset'}; {'id': '157', 'type': 'argument_list', 'children': ['158', '163', '164', '165', '166', '169']}; {'id': '158', 'type': 'attribute', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'question'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'rdclass'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'rdtype'}; {'id': '166', 'type': 'keyword_argument', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '168', 'type': 'True', 'children': []}; {'id': '169', 'type': 'keyword_argument', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'force_unique'}; {'id': '171', 'type': 'True', 'children': []}; {'id': '172', 'type': 'if_statement', 'children': ['173', '176']}; {'id': '173', 'type': 'attribute', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'updating'}; {'id': '176', 'type': 'block', 'children': ['177']}; {'id': '177', 'type': 'expression_statement', 'children': ['178']}; {'id': '178', 'type': 'assignment', 'children': ['179', '182']}; {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'zone_rdclass'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'rdclass'}; {'id': '183', 'type': 'expression_statement', 'children': ['184']}; {'id': '184', 'type': 'call', 'children': ['185', '190']}; {'id': '185', 'type': 'attribute', 'children': ['186', '189']}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'tok'}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'get_eol'}; {'id': '190', 'type': 'argument_list', 'children': []}
|
Process one line from the text format question section.
|
def _decode_temp(byte_1, byte_2):
temp = (byte_1 << 8) + byte_2
if (temp > 32767):
temp = temp - 65536
temp = temp / 10
return temp
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_decode_temp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'byte_1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'byte_2'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '28', '34']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '15'], 'value': '+'}; {'id': '11', 'type': '()', 'children': ['12']}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '14'], 'value': '<<'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'byte_1'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'byte_2'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '21']}; {'id': '17', 'type': '()', 'children': ['18']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': '>'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '32767'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '-'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '65536'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '/'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'temp'}
|
Decode a signed short temperature as two bytes to a single number.
|
def to_vararray(var_instance, bounds):
assert isinstance(var_instance, SymbolVAR)
from symbols import BOUNDLIST
from symbols import VARARRAY
assert isinstance(bounds, BOUNDLIST)
var_instance.__class__ = VARARRAY
var_instance.class_ = CLASS.array
var_instance.bounds = bounds
return var_instance
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_vararray'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'var_instance'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '18', '23', '29', '35', '43', '49']}; {'id': '7', 'type': 'assert_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'var_instance'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'SymbolVAR'}; {'id': '13', 'type': 'import_from_statement', 'children': ['14', '16']}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '16', 'type': 'dotted_name', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'BOUNDLIST'}; {'id': '18', 'type': 'import_from_statement', 'children': ['19', '21']}; {'id': '19', 'type': 'dotted_name', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '21', 'type': 'dotted_name', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'VARARRAY'}; {'id': '23', 'type': 'assert_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'BOUNDLIST'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'var_instance'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'VARARRAY'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'var_instance'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'class_'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'CLASS'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'var_instance'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'var_instance'}
|
Converts a var_instance to a var array one
|
def app_profile_path(cls, project, instance, app_profile):
return google.api_core.path_template.expand(
"projects/{project}/instances/{instance}/appProfiles/{app_profile}",
project=project,
instance=instance,
app_profile=app_profile,
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'app_profile_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'app_profile'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '18']}; {'id': '11', 'type': 'attribute', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'google'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'api_core'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'path_template'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'expand'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '23', '26']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"projects/{project}/instances/{instance}/appProfiles/{app_profile}"'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'app_profile'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'app_profile'}
|
Return a fully-qualified app_profile string.
|
def reloadGraphs(self) :
"reloads the graph list"
r = self.connection.session.get(self.graphsURL)
data = r.json()
if r.status_code == 200 :
self.graphs = {}
for graphData in data["graphs"] :
try :
self.graphs[graphData["_key"]] = GR.getGraphClass(graphData["_key"])(self, graphData)
except KeyError :
self.graphs[graphData["_key"]] = Graph(self, graphData)
else :
raise UpdateError(data["errorMessage"], data)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reloadGraphs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '23', '31']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"reloads the graph list"'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'graphsURL'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37', '90']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '36'], 'value': '=='}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '37', 'type': 'block', 'children': ['38', '44']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'graphs'}; {'id': '43', 'type': 'dictionary', 'children': []}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '49']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'graphData'}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"graphs"'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'try_statement', 'children': ['51', '73']}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '61']}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'graphs'}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'graphData'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"_key"'}; {'id': '61', 'type': 'call', 'children': ['62', '70']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'GR'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'getGraphClass'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'graphData'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"_key"'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'graphData'}; {'id': '73', 'type': 'except_clause', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '85']}; {'id': '78', 'type': 'subscript', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'graphs'}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'graphData'}; {'id': '84', 'type': 'string', 'children': [], 'value': '"_key"'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'Graph'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'graphData'}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'raise_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'UpdateError'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '99']}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"errorMessage"'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'data'}
|
reloads the graph list
|
def find_api_id(self):
allapis = self.client.get_rest_apis()
api_name = self.trigger_settings['api_name']
api_id = None
for api in allapis['items']:
if api['name'] == api_name:
api_id = api['id']
self.log.info("Found API for: %s", api_name)
break
else:
api_id = self.create_api()
return api_id
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_api_id'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '24', '28', '68']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'allapis'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_rest_apis'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'api_name'}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'trigger_settings'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'api_name'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'api_id'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'for_statement', 'children': ['29', '30', '33', '58']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'allapis'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'items'"}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'if_statement', 'children': ['35', '40']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '39'], 'value': '=='}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'api_name'}; {'id': '40', 'type': 'block', 'children': ['41', '47', '57']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'api_id'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': '"Found API for: %s"'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'api_name'}; {'id': '57', 'type': 'break_statement', 'children': []}; {'id': '58', 'type': 'else_clause', 'children': ['59']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'api_id'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'create_api'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'api_id'}
|
Given API name, find API ID.
|
def catCSVs(folder, ouputFileName, removeDups = False) :
strCmd = r %(folder, ouputFileName)
os.system(strCmd)
if removeDups :
removeDuplicates(ouputFileName, ouputFileName)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'catCSVs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ouputFileName'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'removeDups'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '18', '25']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'strCmd'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '15'], 'value': '%'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '15', 'type': 'tuple', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ouputFileName'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'strCmd'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'removeDups'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'removeDuplicates'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ouputFileName'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ouputFileName'}
|
Concatenates all csv in 'folder' and wites the results in 'ouputFileName'. My not work on non Unix systems
|
def colordict(self):
d = {}
i=0
n = len(self.constraints)
for c in self.constraints:
d[c] = cm.jet(1.*i/n)
i+=1
return d
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'colordict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '23', '48']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'constraints'}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '28']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'constraints'}; {'id': '28', 'type': 'block', 'children': ['29', '44']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cm'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'jet'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '43'], 'value': '/'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '*'}; {'id': '41', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'augmented_assignment', 'children': ['46', '47'], 'value': '+='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'd'}
|
Dictionary holding colors that correspond to constraints.
|
def energy(self):
e = 0
for i in range(len(self.state)):
e += self.distance_matrix[self.state[i-1]][self.state[i]]
return e
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'energy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '21']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'augmented_assignment', 'children': ['24', '25'], 'value': '+='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '25', 'type': 'subscript', 'children': ['26', '37']}; {'id': '26', 'type': 'subscript', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'distance_matrix'}; {'id': '30', 'type': 'subscript', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '-'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'e'}
|
Calculates the length of the route.
|
def base_url(klass, space_id, resource_id=None, public=False, environment_id=None, **kwargs):
if public:
environment_slug = ""
if environment_id is not None:
environment_slug = "/environments/{0}".format(environment_id)
return "spaces/{0}{1}/public/content_types".format(space_id, environment_slug)
return super(ContentType, klass).base_url(
space_id,
resource_id=resource_id,
environment_id=environment_id,
**kwargs
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'base_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'space_id'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'resource_id'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'public'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'environment_id'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'dictionary_splat_pattern', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '17', 'type': 'block', 'children': ['18', '47']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'public'}; {'id': '20', 'type': 'block', 'children': ['21', '25', '39']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'environment_slug'}; {'id': '24', 'type': 'string', 'children': [], 'value': '""'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is not'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'environment_id'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'environment_slug'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"/environments/{0}"'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'environment_id'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"spaces/{0}{1}/public/content_types"'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'space_id'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'environment_slug'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '56']}; {'id': '49', 'type': 'attribute', 'children': ['50', '55']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ContentType'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'base_url'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58', '61', '64']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'space_id'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'resource_id'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'resource_id'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'environment_id'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'environment_id'}; {'id': '64', 'type': 'dictionary_splat', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Returns the URI for the content type.
|
def _get_app_config(self, app_name):
matches = [app_config for app_config in apps.get_app_configs()
if app_config.name == app_name]
if not matches:
return
return matches[0]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_app_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '6', 'type': 'block', 'children': ['7', '25', '30']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '12', '19']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'app_config'}; {'id': '12', 'type': 'for_in_clause', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'app_config'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'apps'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_app_configs'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'if_clause', 'children': ['20']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '24'], 'value': '=='}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'app_config'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '28']}; {'id': '26', 'type': 'not_operator', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': []}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}
|
Returns an app config for the given name, not by label.
|
def urlencode(params):
if not isinstance(params, dict):
raise TypeError("Only dicts are supported.")
params = flatten(params)
url_params = OrderedDict()
for param in params:
value = param.pop()
name = parametrize(param)
if isinstance(value, (list, tuple)):
name += "[]"
url_params[name] = value
return urllib_urlencode(url_params, doseq=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'urlencode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '26', '32', '70']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'raise_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Only dicts are supported."'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'url_params'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '35', 'type': 'block', 'children': ['36', '44', '51', '64']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'parametrize'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '59']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '56', 'type': 'tuple', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'augmented_assignment', 'children': ['62', '63'], 'value': '+='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '63', 'type': 'string', 'children': [], 'value': '"[]"'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '69']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'url_params'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'urllib_urlencode'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'url_params'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'doseq'}; {'id': '77', 'type': 'True', 'children': []}
|
Urlencode a multidimensional dict.
|
def _get_s3_files(local_dir, file_info, params):
assert len(file_info) == 1
files = file_info.values()[0]
fnames = []
for k in ["1", "2"]:
if files[k] not in fnames:
fnames.append(files[k])
out = []
for fname in fnames:
bucket, key = fname.replace("s3://", "").split("/", 1)
if params["access_key_id"] == "TEST":
out.append(os.path.join(local_dir, os.path.basename(key)))
else:
out.append(s3.get_file(local_dir, bucket, key, params))
return out
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_s3_files'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'local_dir'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'file_info'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '25', '29', '51', '55', '123']}; {'id': '8', 'type': 'assert_statement', 'children': ['9']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '14'], 'value': '=='}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'file_info'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '18', 'type': 'subscript', 'children': ['19', '24']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'file_info'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'fnames'}; {'id': '28', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '34']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '31', 'type': 'list', 'children': ['32', '33'], 'value': '["1", "2"]'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"1"'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"2"'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '41']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '40'], 'value': 'not in'}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fnames'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fnames'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '54', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '55', 'type': 'for_statement', 'children': ['56', '57', '58']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'fnames'}; {'id': '58', 'type': 'block', 'children': ['59', '77']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '64']}; {'id': '61', 'type': 'pattern_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '64', 'type': 'call', 'children': ['65', '74']}; {'id': '65', 'type': 'attribute', 'children': ['66', '73']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'string', 'children': [], 'value': '"s3://"'}; {'id': '72', 'type': 'string', 'children': [], 'value': '""'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'if_statement', 'children': ['78', '83', '106']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '82'], 'value': '=='}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '81', 'type': 'string', 'children': [], 'value': '"access_key_id"'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"TEST"'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '96']}; {'id': '91', 'type': 'attribute', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'local_dir'}; {'id': '98', 'type': 'call', 'children': ['99', '104']}; {'id': '99', 'type': 'attribute', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '106', 'type': 'else_clause', 'children': ['107']}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 's3'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'get_file'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120', '121', '122']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'local_dir'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '123', 'type': 'return_statement', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'out'}
|
Retrieve s3 files to local directory, handling STORMSeq inputs.
|
def sqlvm_group_create(client, cmd, sql_virtual_machine_group_name, resource_group_name, location, sql_image_offer,
sql_image_sku, domain_fqdn, cluster_operator_account, sql_service_account,
storage_account_url, storage_account_key, cluster_bootstrap_account=None,
file_share_witness_path=None, ou_path=None, tags=None):
tags = tags or {}
wsfc_domain_profile_object = WsfcDomainProfile(domain_fqdn=domain_fqdn,
ou_path=ou_path,
cluster_bootstrap_account=cluster_bootstrap_account,
cluster_operator_account=cluster_operator_account,
sql_service_account=sql_service_account,
file_share_witness_path=file_share_witness_path,
storage_account_url=storage_account_url,
storage_account_primary_key=storage_account_key)
sqlvm_group_object = SqlVirtualMachineGroup(sql_image_offer=sql_image_offer,
sql_image_sku=sql_image_sku,
wsfc_domain_profile=wsfc_domain_profile_object,
location=location,
tags=tags)
LongRunningOperation(cmd.cli_ctx)(sdk_no_wait(False, client.create_or_update, resource_group_name,
sql_virtual_machine_group_name, sqlvm_group_object))
return client.get(resource_group_name, sql_virtual_machine_group_name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sqlvm_group_create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '19', '22', '25']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sql_virtual_machine_group_name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'resource_group_name'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sql_image_offer'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sql_image_sku'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'domain_fqdn'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cluster_operator_account'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'sql_service_account'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'storage_account_url'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'storage_account_key'}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cluster_bootstrap_account'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'file_share_witness_path'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'default_parameter', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ou_path'}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'default_parameter', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29', '35', '65', '86', '105']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '34'], 'value': 'or'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '34', 'type': 'dictionary', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'wsfc_domain_profile_object'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'WsfcDomainProfile'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44', '47', '50', '53', '56', '59', '62']}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'domain_fqdn'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'domain_fqdn'}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ou_path'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ou_path'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cluster_bootstrap_account'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cluster_bootstrap_account'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cluster_operator_account'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'cluster_operator_account'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sql_service_account'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'sql_service_account'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'file_share_witness_path'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'file_share_witness_path'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'storage_account_url'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'storage_account_url'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'storage_account_primary_key'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'storage_account_key'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sqlvm_group_object'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'SqlVirtualMachineGroup'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '74', '77', '80', '83']}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'sql_image_offer'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sql_image_offer'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'sql_image_sku'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'sql_image_sku'}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'wsfc_domain_profile'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'wsfc_domain_profile_object'}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '94']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'LongRunningOperation'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'cli_ctx'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'sdk_no_wait'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '99', '102', '103', '104']}; {'id': '98', 'type': 'False', 'children': []}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'create_or_update'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'resource_group_name'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'sql_virtual_machine_group_name'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'sqlvm_group_object'}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'resource_group_name'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'sql_virtual_machine_group_name'}
|
Creates a SQL virtual machine group.
|
def home(request):
try:
DBSession.query(User).first()
except DBAPIError:
return Response(
conn_err_msg,
content_type="text/plain",
status_int=500,
)
return {"project": "pyramid_tut"}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'home'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'block', 'children': ['6', '33']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '19']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '18']}; {'id': '10', 'type': 'attribute', 'children': ['11', '17']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'DBSession'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'except_clause', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'DBAPIError'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '30']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'conn_err_msg'}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"text/plain"'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'status_int'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '500'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'dictionary', 'children': ['35']}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"project"'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"pyramid_tut"'}
|
Try to connect to database, and list available examples.
|
def _read_depth_images(self, num_images):
depth_images = self._ros_read_images(self._depth_image_buffer, num_images, self.staleness_limit)
for i in range(0, num_images):
depth_images[i] = depth_images[i] * MM_TO_METERS
if self._flip_images:
depth_images[i] = np.flipud(depth_images[i])
depth_images[i] = np.fliplr(depth_images[i])
depth_images[i] = DepthImage(depth_images[i], frame=self._frame)
return depth_images
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_depth_images'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'num_images'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '87']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_ros_read_images'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18', '19']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_depth_image_buffer'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'num_images'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'staleness_limit'}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '29']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'num_images'}; {'id': '29', 'type': 'block', 'children': ['30', '40', '71']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '39'], 'value': '*'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'MM_TO_METERS'}; {'id': '40', 'type': 'if_statement', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_flip_images'}; {'id': '44', 'type': 'block', 'children': ['45', '58']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'flipud'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'fliplr'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '76']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'DepthImage'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '82']}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'depth_images'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '82', 'type': 'keyword_argument', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_frame'}; {'id': '87', 'type': 'return_statement', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'depth_images'}
|
Reads depth images from the device
|
def load_yaml(fname):
yaml = YAML(typ="safe")
yaml.allow_duplicate_keys = True
HassSafeConstructor.name = fname
yaml.Constructor = HassSafeConstructor
with open(fname, encoding="utf-8") as conf_file:
return yaml.load(conf_file) or {}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_yaml'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '21', '27', '33']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'YAML'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'keyword_argument', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"safe"'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'allow_duplicate_keys'}; {'id': '20', 'type': 'True', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'HassSafeConstructor'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'Constructor'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'HassSafeConstructor'}; {'id': '33', 'type': 'with_statement', 'children': ['34', '46']}; {'id': '34', 'type': 'with_clause', 'children': ['35']}; {'id': '35', 'type': 'with_item', 'children': ['36']}; {'id': '36', 'type': 'as_pattern', 'children': ['37', '44']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '44', 'type': 'as_pattern_target', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'conf_file'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '55'], 'value': 'or'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'conf_file'}; {'id': '55', 'type': 'dictionary', 'children': []}
|
Load a YAML file.
|
def cli(sequencepath, report, refseq_database):
main(sequencepath, report, refseq_database, num_threads=multiprocessing.cpu_count())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sequencepath'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'refseq_database'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13', '14', '15']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'sequencepath'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'refseq_database'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'num_threads'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'multiprocessing'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cpu_count'}; {'id': '21', 'type': 'argument_list', 'children': []}
|
Pass command line arguments to, and run the feature extraction functions
|
def dynare_import(filename,full_output=False, debug=False):
import os
basename = os.path.basename(filename)
fname = re.compile('(.*)\.(.*)').match(basename).group(1)
f = open(filename)
txt = f.read()
model = parse_dynare_text(txt,full_output=full_output, debug=debug)
model.name = fname
return model
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dynare_import'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'full_output'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '15', '26', '45', '52', '60', '73', '79']}; {'id': '12', 'type': 'import_statement', 'children': ['13']}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '29', 'type': 'call', 'children': ['30', '43']}; {'id': '30', 'type': 'attribute', 'children': ['31', '42']}; {'id': '31', 'type': 'call', 'children': ['32', '40']}; {'id': '32', 'type': 'attribute', 'children': ['33', '39']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'(.*)\\.(.*)'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'txt'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'parse_dynare_text'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '70']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'txt'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'full_output'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'full_output'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'model'}
|
Imports model defined in specified file
|
def start(self, ccallbacks=None):
self.__manage_g = gevent.spawn(self.__manage_connections, ccallbacks)
self.__ready_ev.wait()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ccallbacks'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '23']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '__manage_g'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'gevent'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'spawn'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '__manage_connections'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ccallbacks'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '__ready_ev'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'wait'}; {'id': '30', 'type': 'argument_list', 'children': []}
|
Establish and maintain connections.
|
def busy_display():
sys.stdout.write("\033[?25l")
sys.stdout.flush()
for x in range(1800):
symb = ['\\', '|', '/', '-']
sys.stdout.write("\033[D{}".format(symb[x % 4]))
sys.stdout.flush()
gevent.sleep(0.1)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'busy_display'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '22']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'call', 'children': ['7', '12']}; {'id': '7', 'type': 'attribute', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"\\033[?25l"'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '28']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1800'}; {'id': '28', 'type': 'block', 'children': ['29', '37', '55', '63']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'symb'}; {'id': '32', 'type': 'list', 'children': ['33', '34', '35', '36'], 'value': "['\\\\', '|', '/', '-']"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'\\\\'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'|'"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"\\033[D{}"'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'symb'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '%'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'gevent'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'float', 'children': [], 'value': '0.1'}
|
Display animation to show activity.
|
def _try_import(module_name):
try:
mod = importlib.import_module(module_name)
return mod
except ImportError:
err_msg = ("Tried importing %s but failed. See setup.py extras_require. "
"The dataset you are trying to use may have additional "
"dependencies.")
utils.reraise(err_msg)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_try_import'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'module_name'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '19']}; {'id': '7', 'type': 'block', 'children': ['8', '17']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'mod'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'importlib'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'import_module'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'module_name'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'mod'}; {'id': '19', 'type': 'except_clause', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '21', 'type': 'block', 'children': ['22', '30']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'err_msg'}; {'id': '25', 'type': '()', 'children': ['26']}; {'id': '26', 'type': 'concatenated_string', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"Tried importing %s but failed. See setup.py extras_require. "'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"The dataset you are trying to use may have additional "'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"dependencies."'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'reraise'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'err_msg'}
|
Try importing a module, with an informative error message on failure.
|
def treeplot(self, qlist, credible_interval):
for y, _, label, values, color in self.iterator():
ntiles = np.percentile(values.flatten(), qlist)
ntiles[0], ntiles[-1] = hpd(values.flatten(), credible_interval)
yield y, label, ntiles, color
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'treeplot'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'qlist'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'credible_interval'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '15', '20']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11', '12', '13', '14']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'iterator'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '35', '54']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ntiles'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'percentile'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '34']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'qlist'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '45']}; {'id': '37', 'type': 'pattern_list', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ntiles'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ntiles'}; {'id': '43', 'type': 'unary_operator', 'children': ['44'], 'value': '-'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'hpd'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '53']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'credible_interval'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'yield', 'children': ['56']}; {'id': '56', 'type': 'expression_list', 'children': ['57', '58', '59', '60']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ntiles'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'color'}
|
Get data for each treeplot for the variable.
|
def worker_loop_v1(dataset, key_queue, data_queue, batchify_fn):
while True:
idx, samples = key_queue.get()
if idx is None:
break
batch = batchify_fn([dataset[i] for i in samples])
data_queue.put((idx, batch))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'worker_loop_v1'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key_queue'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data_queue'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'batchify_fn'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'while_statement', 'children': ['10', '11']}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '22', '28', '41']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'pattern_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'samples'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key_queue'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'is'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'break_statement', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'batch'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'batchify_fn'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'list_comprehension', 'children': ['35', '38']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '38', 'type': 'for_in_clause', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'samples'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data_queue'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'tuple', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'batch'}
|
Worker loop for multiprocessing DataLoader.
|
def restore(self):
if self.proxy_object is None:
if self.getter:
setattr(self.getter_class, self.attr_name, self.getter)
elif self.is_local:
setattr(self.orig_object, self.attr_name, self.orig_value)
else:
delattr(self.orig_object, self.attr_name)
else:
setattr(sys.modules[self.orig_object.__module__],
self.orig_object.__name__,
self.orig_object)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'restore'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '61']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'proxy_object'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17', '31', '49']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getter'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '25', '28']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'getter_class'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'attr_name'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'getter'}; {'id': '31', 'type': 'elif_clause', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'is_local'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43', '46']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'orig_object'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'attr_name'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'orig_value'}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'delattr'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'orig_object'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'attr_name'}; {'id': '61', 'type': 'else_clause', 'children': ['62']}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '76', '81']}; {'id': '67', 'type': 'subscript', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'orig_object'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': '__module__'}; {'id': '76', 'type': 'attribute', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'orig_object'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'orig_object'}
|
Restore the saved value for the attribute of the object.
|
def _array2cstr(arr):
out = StringIO()
np.save(out, arr)
return b64encode(out.getvalue())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_array2cstr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '20']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'StringIO'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'b64encode'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'getvalue'}; {'id': '28', 'type': 'argument_list', 'children': []}
|
Serializes a numpy array to a compressed base64 string
|
def search_fetch_force(request, id, redirect_to):
search = Search.objects.get(id=id)
search.fetch(force=True)
msg = _("Fetched tweets for %s" % search.criteria)
messages.success(request, msg, fail_silently=True)
return HttpResponseRedirect(redirect_to)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search_fetch_force'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'redirect_to'}; {'id': '7', 'type': 'block', 'children': ['8', '21', '30', '41', '52']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Search'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'fetch'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '29', 'type': 'True', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '%'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"Fetched tweets for %s"'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'criteria'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'messages'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48', '49']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fail_silently'}; {'id': '51', 'type': 'True', 'children': []}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'HttpResponseRedirect'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'redirect_to'}
|
Forcibly fetch tweets for the search
|
def listDatasetAccessTypes(self, dataset_access_type=""):
if isinstance(dataset_access_type, basestring):
try:
dataset_access_type = str(dataset_access_type)
except:
dbsExceptionHandler('dbsException-invalid-input', 'dataset_access_type given is not valid : %s' %dataset_access_type)
else:
dbsExceptionHandler('dbsException-invalid-input', 'dataset_access_type given is not valid : %s' %dataset_access_type)
conn = self.dbi.connection()
try:
plist = self.datasetAccessType.execute(conn, dataset_access_type.upper())
result = [{}]
if plist:
t = []
for i in plist:
for k, v in i.iteritems():
t.append(v)
result[0]['dataset_access_type'] = t
return result
finally:
if conn:
conn.close()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'listDatasetAccessTypes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dataset_access_type'}; {'id': '7', 'type': 'string', 'children': [], 'value': '""'}; {'id': '8', 'type': 'block', 'children': ['9', '45', '55']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15', '35']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dataset_access_type'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'basestring'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'try_statement', 'children': ['17', '25']}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dataset_access_type'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dataset_access_type'}; {'id': '25', 'type': 'except_clause', 'children': ['26']}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dbsExceptionHandler'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'dbsException-invalid-input'"}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '%'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'dataset_access_type given is not valid : %s'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dataset_access_type'}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dbsExceptionHandler'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'dbsException-invalid-input'"}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '%'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'dataset_access_type given is not valid : %s'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dataset_access_type'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dbi'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'try_statement', 'children': ['56', '116']}; {'id': '56', 'type': 'block', 'children': ['57', '73', '78', '114']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'plist'}; {'id': '60', 'type': 'call', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'datasetAccessType'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'dataset_access_type'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '72', 'type': 'argument_list', 'children': []}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '76', 'type': 'list', 'children': ['77'], 'value': '[{}]'}; {'id': '77', 'type': 'dictionary', 'children': []}; {'id': '78', 'type': 'if_statement', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'plist'}; {'id': '80', 'type': 'block', 'children': ['81', '85', '106']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '84', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '85', 'type': 'for_statement', 'children': ['86', '87', '88']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'plist'}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'for_statement', 'children': ['90', '93', '98']}; {'id': '90', 'type': 'pattern_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '97', 'type': 'argument_list', 'children': []}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '113']}; {'id': '108', 'type': 'subscript', 'children': ['109', '112']}; {'id': '109', 'type': 'subscript', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '111', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '112', 'type': 'string', 'children': [], 'value': "'dataset_access_type'"}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '116', 'type': 'finally_clause', 'children': ['117']}; {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'if_statement', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '126', 'type': 'argument_list', 'children': []}
|
List dataset access types
|
def json_wrap(function, *args, **kwargs):
try:
response = json.loads(function(*args, **kwargs).content)
if 'data' in response:
return response['data'] or True
else:
return response
except Exception as exc:
raise ClientException(exc)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'json_wrap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'try_statement', 'children': ['11', '44']}; {'id': '11', 'type': 'block', 'children': ['12', '29']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '28']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '26']}; {'id': '24', 'type': 'list_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '26', 'type': 'dictionary_splat', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '33', '40']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'in'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '39'], 'value': 'or'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '39', 'type': 'True', 'children': []}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '44', 'type': 'except_clause', 'children': ['45', '49']}; {'id': '45', 'type': 'as_pattern', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '47', 'type': 'as_pattern_target', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'raise_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ClientException'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'exc'}
|
Return the json content of a function that returns a request
|
def max(cls):
max_recid = db.session.query(func.max(cls.recid)).scalar()
return max_recid if max_recid else 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'max'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '28']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'max_recid'}; {'id': '9', 'type': 'call', 'children': ['10', '27']}; {'id': '10', 'type': 'attribute', 'children': ['11', '26']}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'recid'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'scalar'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'conditional_expression', 'children': ['30', '31', '32'], 'value': 'if'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'max_recid'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'max_recid'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}
|
Get max record identifier.
|
def default_user_agent(name="python-requests"):
_implementation = platform.python_implementation()
if _implementation == 'CPython':
_implementation_version = platform.python_version()
elif _implementation == 'PyPy':
_implementation_version = '%s.%s.%s' % (sys.pypy_version_info.major,
sys.pypy_version_info.minor,
sys.pypy_version_info.micro)
if sys.pypy_version_info.releaselevel != 'final':
_implementation_version = ''.join([_implementation_version, sys.pypy_version_info.releaselevel])
elif _implementation == 'Jython':
_implementation_version = platform.python_version()
elif _implementation == 'IronPython':
_implementation_version = platform.python_version()
else:
_implementation_version = 'Unknown'
try:
p_system = platform.system()
p_release = platform.release()
except IOError:
p_system = 'Unknown'
p_release = 'Unknown'
return " ".join(['%s/%s' % (name, __version__),
'%s/%s' % (_implementation, _implementation_version),
'%s/%s' % (p_system, p_release)])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'default_user_agent'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'string', 'children': [], 'value': '"python-requests"'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '111', '140']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_implementation'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'python_implementation'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20', '29', '79', '92', '105']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': '=='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_implementation'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'CPython'"}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'python_version'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'elif_clause', 'children': ['30', '33']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '=='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_implementation'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'PyPy'"}; {'id': '33', 'type': 'block', 'children': ['34', '55']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '%'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'%s.%s.%s'"}; {'id': '39', 'type': 'tuple', 'children': ['40', '45', '50']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'pypy_version_info'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'major'}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'pypy_version_info'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'minor'}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'pypy_version_info'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'micro'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '63']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '62'], 'value': '!='}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pypy_version_info'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'releaselevel'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'final'"}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': "''"}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'list', 'children': ['73', '74'], 'value': '[_implementation_version, sys.pypy_version_info.releaselevel]'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '74', 'type': 'attribute', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'pypy_version_info'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'releaselevel'}; {'id': '79', 'type': 'elif_clause', 'children': ['80', '83']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': '=='}; {'id': '81', 'type': 'identifier', 'children': [], 'value': '_implementation'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'Jython'"}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'python_version'}; {'id': '91', 'type': 'argument_list', 'children': []}; {'id': '92', 'type': 'elif_clause', 'children': ['93', '96']}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': '=='}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_implementation'}; {'id': '95', 'type': 'string', 'children': [], 'value': "'IronPython'"}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'python_version'}; {'id': '104', 'type': 'argument_list', 'children': []}; {'id': '105', 'type': 'else_clause', 'children': ['106']}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '110', 'type': 'string', 'children': [], 'value': "'Unknown'"}; {'id': '111', 'type': 'try_statement', 'children': ['112', '129']}; {'id': '112', 'type': 'block', 'children': ['113', '121']}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'p_system'}; {'id': '116', 'type': 'call', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '120', 'type': 'argument_list', 'children': []}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'p_release'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '128', 'type': 'argument_list', 'children': []}; {'id': '129', 'type': 'except_clause', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '131', 'type': 'block', 'children': ['132', '136']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'p_system'}; {'id': '135', 'type': 'string', 'children': [], 'value': "'Unknown'"}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'p_release'}; {'id': '139', 'type': 'string', 'children': [], 'value': "'Unknown'"}; {'id': '140', 'type': 'return_statement', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'list', 'children': ['147', '152', '157'], 'value': "['%s/%s' % (name, __version__),\n '%s/%s' % (_implementation, _implementation_version),\n '%s/%s' % (p_system, p_release)]"}; {'id': '147', 'type': 'binary_operator', 'children': ['148', '149'], 'value': '%'}; {'id': '148', 'type': 'string', 'children': [], 'value': "'%s/%s'"}; {'id': '149', 'type': 'tuple', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': '__version__'}; {'id': '152', 'type': 'binary_operator', 'children': ['153', '154'], 'value': '%'}; {'id': '153', 'type': 'string', 'children': [], 'value': "'%s/%s'"}; {'id': '154', 'type': 'tuple', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': '_implementation'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': '_implementation_version'}; {'id': '157', 'type': 'binary_operator', 'children': ['158', '159'], 'value': '%'}; {'id': '158', 'type': 'string', 'children': [], 'value': "'%s/%s'"}; {'id': '159', 'type': 'tuple', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'p_system'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'p_release'}
|
Return a string representing the default user agent.
|
def identity(ctx, variant_id):
if not variant_id:
LOG.warning("Please provide a variant id")
ctx.abort()
adapter = ctx.obj['adapter']
version = ctx.obj['version']
LOG.info("Search variants {0}".format(adapter))
result = adapter.get_clusters(variant_id)
if result.count() == 0:
LOG.info("No hits for variant %s", variant_id)
return
for res in result:
click.echo(res)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'identity'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'variant_id'}; {'id': '6', 'type': 'block', 'children': ['7', '24', '32', '40', '52', '61', '79']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '10']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'variant_id'}; {'id': '10', 'type': 'block', 'children': ['11', '18']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"Please provide a variant id"'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'abort'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'adapter'"}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '35', 'type': 'subscript', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'version'"}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"Search variants {0}"'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'get_clusters'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'variant_id'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '69']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '68'], 'value': '=='}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '69', 'type': 'block', 'children': ['70', '78']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'string', 'children': [], 'value': '"No hits for variant %s"'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'variant_id'}; {'id': '78', 'type': 'return_statement', 'children': []}; {'id': '79', 'type': 'for_statement', 'children': ['80', '81', '82']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'res'}
|
Check how well SVs are working in the database
|
def weighted_tanimoto(a, b, weights):
weighted = lambda s: map(lambda (x,y): float(x)*float(y), zip(s, weights))
return tanimoto_coefficient(weighted(a), weighted(b))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'weighted_tanimoto'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'weights'}; {'id': '7', 'type': 'block', 'children': ['8', '36']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'weighted'}; {'id': '11', 'type': 'lambda', 'children': ['12', '14']}; {'id': '12', 'type': 'lambda_parameters', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '31']}; {'id': '17', 'type': 'lambda', 'children': ['18', '22']}; {'id': '18', 'type': 'lambda_parameters', 'children': ['19']}; {'id': '19', 'type': 'tuple_pattern', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '27'], 'value': '*'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'weights'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'tanimoto_coefficient'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '44']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'weighted'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'weighted'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'b'}
|
Same as the Tanimoto coefficient, but wit weights for each dimension.
|
def ssh_config(ssh_user, ssh_private_key_file):
try:
ssh_file = NamedTemporaryFile(delete=False, mode='w+')
ssh_file.write('Host *\n')
ssh_file.write(' IdentityFile %s\n' % ssh_private_key_file)
ssh_file.write(' User %s' % ssh_user)
ssh_file.close()
yield ssh_file.name
finally:
with ignored(OSError):
os.remove(ssh_file.name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ssh_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ssh_user'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ssh_private_key_file'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '57']}; {'id': '8', 'type': 'block', 'children': ['9', '21', '28', '37', '46', '52']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ssh_file'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'NamedTemporaryFile'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'w+'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ssh_file'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'Host *\\n'"}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ssh_file'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '%'}; {'id': '35', 'type': 'string', 'children': [], 'value': "' IdentityFile %s\\n'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ssh_private_key_file'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ssh_file'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '%'}; {'id': '44', 'type': 'string', 'children': [], 'value': "' User %s'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ssh_user'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ssh_file'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'yield', 'children': ['54']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ssh_file'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '57', 'type': 'finally_clause', 'children': ['58']}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'with_statement', 'children': ['60', '66']}; {'id': '60', 'type': 'with_clause', 'children': ['61']}; {'id': '61', 'type': 'with_item', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ignored'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ssh_file'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Create temporary ssh config file.
|
def c_str(string):
if not isinstance(string, str):
string = string.decode('ascii')
return ctypes.c_char_p(string.encode('utf-8'))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'c_str'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '5', 'type': 'block', 'children': ['6', '23']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'ascii'"}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'c_char_p'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'utf-8'"}
|
Convert a python string to C string.
|
def create_database_session(engine):
try:
Session = sessionmaker(bind=engine)
return Session()
except OperationalError as e:
raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_database_session'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '21']}; {'id': '7', 'type': 'block', 'children': ['8', '17']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Session'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'sessionmaker'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'bind'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Session'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'except_clause', 'children': ['22', '26']}; {'id': '22', 'type': 'as_pattern', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'OperationalError'}; {'id': '24', 'type': 'as_pattern_target', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'raise_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'DatabaseError'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '40']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '33', 'type': 'subscript', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '42', 'type': 'subscript', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'orig'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}
|
Connect to the database
|
def __load_countries(self, db):
try:
countries = self.__read_countries_file()
except IOError as e:
raise LoadError(str(e))
try:
with db.connect() as session:
for country in countries:
session.add(country)
except Exception as e:
raise LoadError(str(e))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__load_countries'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '6', 'type': 'block', 'children': ['7', '31']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'countries'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '__read_countries_file'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'except_clause', 'children': ['18', '22']}; {'id': '18', 'type': 'as_pattern', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '20', 'type': 'as_pattern_target', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'raise_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'LoadError'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '31', 'type': 'try_statement', 'children': ['32', '56']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'with_statement', 'children': ['34', '44']}; {'id': '34', 'type': 'with_clause', 'children': ['35']}; {'id': '35', 'type': 'with_item', 'children': ['36']}; {'id': '36', 'type': 'as_pattern', 'children': ['37', '42']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'as_pattern_target', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'for_statement', 'children': ['46', '47', '48']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'country'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'countries'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'country'}; {'id': '56', 'type': 'except_clause', 'children': ['57', '61']}; {'id': '57', 'type': 'as_pattern', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '59', 'type': 'as_pattern_target', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'raise_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'LoadError'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'e'}
|
Load the list of countries
|
def select_locale_by_request(self, request, locales=()):
default_locale = locales and locales[0] or self.cfg.default_locale
if len(locales) == 1 or 'ACCEPT-LANGUAGE' not in request.headers:
return default_locale
ulocales = [
(q, locale_delim_re.split(v)[0])
for v, q in parse_accept_header(request.headers['ACCEPT-LANGUAGE'])
]
ulocales.sort()
ulocales.reverse()
for locale in locales:
for _, ulocale in ulocales:
ulocale = locale_delim_re.split(ulocale)[0]
if ulocale.lower() == locale.lower():
return ulocale
return ulocales[0][1]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_locale_by_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'locales'}; {'id': '8', 'type': 'tuple', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '24', '40', '66', '72', '78', '114']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'default_locale'}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '19'], 'value': 'or'}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '16'], 'value': 'and'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'locales'}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'locales'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'default_locale'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '37']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '32'], 'value': 'or'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '31'], 'value': '=='}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'locales'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'not in'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'ACCEPT-LANGUAGE'"}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'default_locale'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ulocales'}; {'id': '43', 'type': 'list_comprehension', 'children': ['44', '54']}; {'id': '44', 'type': 'tuple', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '46', 'type': 'subscript', 'children': ['47', '53']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'locale_delim_re'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '58']}; {'id': '55', 'type': 'pattern_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'parse_accept_header'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'subscript', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'ACCEPT-LANGUAGE'"}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ulocales'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'ulocales'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'for_statement', 'children': ['79', '80', '81']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'locales'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'for_statement', 'children': ['83', '86', '87']}; {'id': '83', 'type': 'pattern_list', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ulocale'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'ulocales'}; {'id': '87', 'type': 'block', 'children': ['88', '99']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'ulocale'}; {'id': '91', 'type': 'subscript', 'children': ['92', '98']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'locale_delim_re'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'ulocale'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '99', 'type': 'if_statement', 'children': ['100', '111']}; {'id': '100', 'type': 'comparison_operator', 'children': ['101', '106'], 'value': '=='}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'ulocale'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '105', 'type': 'argument_list', 'children': []}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '110', 'type': 'argument_list', 'children': []}; {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'return_statement', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ulocale'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'subscript', 'children': ['116', '119']}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'ulocales'}; {'id': '118', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '119', 'type': 'integer', 'children': [], 'value': '1'}
|
Choose an user's locales by request.
|
def _load_rules(forcefield):
rules = dict()
for rule_name, smarts in forcefield.atomTypeDefinitions.items():
overrides = forcefield.atomTypeOverrides.get(rule_name)
if overrides is not None:
overrides = set(overrides)
else:
overrides = set()
rules[rule_name] = SMARTSGraph(smarts_string=smarts,
parser=forcefield.parser,
name=rule_name,
overrides=overrides)
return rules
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_rules'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'forcefield'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '77']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'rules'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'for_statement', 'children': ['13', '16', '23']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'rule_name'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'smarts'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'forcefield'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'atomTypeDefinitions'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24', '35', '55']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'forcefield'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'atomTypeOverrides'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'rule_name'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '39', '47']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'is not'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '60']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'rules'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'rule_name'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'SMARTSGraph'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '66', '71', '74']}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'smarts_string'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'smarts'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'forcefield'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'rule_name'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'overrides'}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'rules'}
|
Load atomtyping rules from a forcefield into SMARTSGraphs.
|
def load_data(self):
try:
df = self.live_quote_arg_func(self.tickers)
for index, ticker in enumerate(self.tickers):
ticker_info = df.loc[index]
self.ticker_dict[ticker].append(ticker_info['price'],
ticker_info['volume'],
ticker_info['amount'],
ticker_info['time'])
except Exception:
raise ValueError('Polling thread exception')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '60']}; {'id': '7', 'type': 'block', 'children': ['8', '19']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'live_quote_arg_func'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tickers'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '23', '29']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ticker'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'tickers'}; {'id': '29', 'type': 'block', 'children': ['30', '38']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ticker_info'}; {'id': '33', 'type': 'subscript', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '47']}; {'id': '40', 'type': 'attribute', 'children': ['41', '46']}; {'id': '41', 'type': 'subscript', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ticker_dict'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ticker'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '51', '54', '57']}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ticker_info'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'price'"}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ticker_info'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'volume'"}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ticker_info'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'amount'"}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ticker_info'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'time'"}; {'id': '60', 'type': 'except_clause', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'raise_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'Polling thread exception'"}
|
Overwrite this for new source data structures
|
def resource(self):
if self._resource:
return self._resource
elif self.binding:
return self.binding.resource
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resource'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10', '15']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_resource'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_resource'}; {'id': '15', 'type': 'elif_clause', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'binding'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'binding'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'resource'}
|
Resource associated with operation.
|
def append_rally_point(self, p):
if (self.rally_count() > 9):
print("Can't have more than 10 rally points, not adding.")
return
self.rally_points.append(p)
self.reindex()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append_rally_point'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '6', 'type': 'block', 'children': ['7', '23', '32']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '16']}; {'id': '8', 'type': '()', 'children': ['9']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '15'], 'value': '>'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'rally_count'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '16', 'type': 'block', 'children': ['17', '22']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"Can\'t have more than 10 rally points, not adding."'}; {'id': '22', 'type': 'return_statement', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'rally_points'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'reindex'}; {'id': '37', 'type': 'argument_list', 'children': []}
|
add rallypoint to end of list
|
def to_dict(self):
if not self.url:
return None
return {
'url': self.url,
'width': self.width,
'height': self.height
}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'dictionary', 'children': ['16', '21', '26']}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'url'"}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'width'"}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'height'"}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'height'}
|
Convert Image into raw dictionary data.
|
def fetch(index, tokens):
if len(tokens) == 0:
return set()
return set.intersection(*[set(index.get(token, [])) for token in tokens])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '=='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'intersection'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'list_splat', 'children': ['26']}; {'id': '26', 'type': 'list_comprehension', 'children': ['27', '37']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '36', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '37', 'type': 'for_in_clause', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'tokens'}
|
Fetch the codes from given tokens
|
def read_header(self):
with fopen(self.vpk_path, 'rb') as f:
(self.signature,
self.version,
self.tree_length
) = struct.unpack("3I", f.read(3*4))
if self.signature != 0x55aa1234:
raise ValueError("File is not VPK (invalid magic)")
elif self.version == 1:
self.header_length += 4*3
elif self.version == 2:
(self.embed_chunk_length,
self.chunk_hashes_length,
self.self_hashes_length,
self.signature_length
) = struct.unpack("4I", f.read(4*4))
self.header_length += 4*7
f.seek(self.tree_length + self.embed_chunk_length + self.chunk_hashes_length, 1)
assert self.self_hashes_length == 48, "Self hashes section size mismatch"
(self.tree_checksum,
self.chunk_hashes_checksum,
self.file_checksum,
) = struct.unpack("16s16s16s", f.read(16*3))
else:
raise ValueError("Invalid header, or unsupported version")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_header'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '19']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'as_pattern', 'children': ['10', '17']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fopen'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'vpk_path'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '17', 'type': 'as_pattern_target', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '19', 'type': 'block', 'children': ['20', '46']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '32']}; {'id': '22', 'type': 'tuple_pattern', 'children': ['23', '26', '29']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'signature'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tree_length'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'unpack'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"3I"'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '*'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '52', '58', '73', '168']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '51'], 'value': '!='}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'signature'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0x55aa1234'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'raise_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"File is not VPK (invalid magic)"'}; {'id': '58', 'type': 'elif_clause', 'children': ['59', '64']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '63'], 'value': '=='}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'augmented_assignment', 'children': ['67', '70'], 'value': '+='}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'header_length'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '*'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '73', 'type': 'elif_clause', 'children': ['74', '79']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '78'], 'value': '=='}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '79', 'type': 'block', 'children': ['80', '109', '117', '135', '142']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '95']}; {'id': '82', 'type': 'tuple_pattern', 'children': ['83', '86', '89', '92']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'embed_chunk_length'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'chunk_hashes_length'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self_hashes_length'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'signature_length'}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'unpack'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': '"4I"'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'binary_operator', 'children': ['107', '108'], 'value': '*'}; {'id': '107', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '108', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'augmented_assignment', 'children': ['111', '114'], 'value': '+='}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'header_length'}; {'id': '114', 'type': 'binary_operator', 'children': ['115', '116'], 'value': '*'}; {'id': '115', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '116', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '134']}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '131'], 'value': '+'}; {'id': '124', 'type': 'binary_operator', 'children': ['125', '128'], 'value': '+'}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'tree_length'}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'embed_chunk_length'}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'chunk_hashes_length'}; {'id': '134', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '135', 'type': 'assert_statement', 'children': ['136', '141']}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '140'], 'value': '=='}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'self_hashes_length'}; {'id': '140', 'type': 'integer', 'children': [], 'value': '48'}; {'id': '141', 'type': 'string', 'children': [], 'value': '"Self hashes section size mismatch"'}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}; {'id': '143', 'type': 'assignment', 'children': ['144', '154']}; {'id': '144', 'type': 'tuple_pattern', 'children': ['145', '148', '151']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'tree_checksum'}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'chunk_hashes_checksum'}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'file_checksum'}; {'id': '154', 'type': 'call', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'unpack'}; {'id': '158', 'type': 'argument_list', 'children': ['159', '160']}; {'id': '159', 'type': 'string', 'children': [], 'value': '"16s16s16s"'}; {'id': '160', 'type': 'call', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}; {'id': '165', 'type': 'binary_operator', 'children': ['166', '167'], 'value': '*'}; {'id': '166', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '167', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '168', 'type': 'else_clause', 'children': ['169']}; {'id': '169', 'type': 'block', 'children': ['170']}; {'id': '170', 'type': 'raise_statement', 'children': ['171']}; {'id': '171', 'type': 'call', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '173', 'type': 'argument_list', 'children': ['174']}; {'id': '174', 'type': 'string', 'children': [], 'value': '"Invalid header, or unsupported version"'}
|
Reads VPK file header from the file
|
def _read_temp(data):
tout = StringIO()
tout.write(data)
tout.seek(0)
output = tout.readlines()
tout.close()
return output
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_temp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '19', '26', '34', '40']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tout'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'StringIO'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'tout'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tout'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tout'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'readlines'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'tout'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'output'}
|
Return what would be written to disk
|
def stop_jobs(self, job_ids=None):
self.lock()
jobs = self.get_jobs(job_ids)
for job in jobs:
if job.status in ('executing', 'queued', 'waiting') and job.queue_name == 'local':
logger.info("Reset job '%s' (%s) in the database", job.name, self._format_log(job.id))
job.submit()
self.session.commit()
self.unlock()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop_jobs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'job_ids'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '15', '24', '68', '76']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_jobs'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'job_ids'}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '27']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '43']}; {'id': '29', 'type': 'boolean_operator', 'children': ['30', '38'], 'value': 'and'}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '34'], 'value': 'in'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '34', 'type': 'tuple', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'executing'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'queued'"}; {'id': '37', 'type': 'string', 'children': [], 'value': "'waiting'"}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '42'], 'value': '=='}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'queue_name'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'local'"}; {'id': '43', 'type': 'block', 'children': ['44', '62']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51', '54']}; {'id': '50', 'type': 'string', 'children': [], 'value': '"Reset job \'%s\' (%s) in the database"'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_format_log'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'submit'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'commit'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'unlock'}; {'id': '81', 'type': 'argument_list', 'children': []}
|
Resets the status of the job to 'submitted' when they are labeled as 'executing'.
|
def cl_picard(self, command, options, memscale=None):
options = ["%s=%s" % (x, y) for x, y in options]
options.append("VALIDATION_STRINGENCY=SILENT")
return self._get_picard_cmd(command, memscale=memscale) + options
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cl_picard'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'memscale'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '25', '32']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '14', 'type': 'list_comprehension', 'children': ['15', '20']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '%'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"%s=%s"'}; {'id': '17', 'type': 'tuple', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"VALIDATION_STRINGENCY=SILENT"'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '43'], 'value': '+'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_get_picard_cmd'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'memscale'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'memscale'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'options'}
|
Prepare a Picard commandline.
|
def strip( text ):
members = [attr for attr in Colors.__dict__.keys() if not attr.startswith( "__" ) and not attr == 'strip']
for c in members:
text = text.replace( vars( Colors )[c], '' )
return text
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'strip'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'block', 'children': ['6', '33', '52']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'members'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '11', '20']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '11', 'type': 'for_in_clause', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Colors'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'if_clause', 'children': ['21']}; {'id': '21', 'type': 'boolean_operator', 'children': ['22', '29'], 'value': 'and'}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"__"'}; {'id': '29', 'type': 'not_operator', 'children': ['30']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '=='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'strip'"}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'members'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '51']}; {'id': '45', 'type': 'subscript', 'children': ['46', '50']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Colors'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '51', 'type': 'string', 'children': [], 'value': "''"}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'text'}
|
Strips all color codes from a text.
|
def DiffArrayObjects(self, oldObj, newObj, isElementLinks=False):
if oldObj == newObj:
return True
if not oldObj or not newObj:
return False
if len(oldObj) != len(newObj):
__Log__.debug('DiffArrayObjects: Array lengths do not match %d != %d'
% (len(oldObj), len(newObj)))
return False
firstObj = oldObj[0]
if IsPrimitiveType(firstObj):
return self.DiffPrimitiveArrays(oldObj, newObj)
elif isinstance(firstObj, types.ManagedObject):
return self.DiffAnyArrays(oldObj, newObj, isElementLinks)
elif isinstance(firstObj, types.DataObject):
return self.DiffDoArrays(oldObj, newObj, isElementLinks)
else:
raise TypeError("Unknown type: %s" % oldObj.__class__)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DiffArrayObjects'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'isElementLinks'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '18', '27', '57', '63']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': '=='}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'True', 'children': []}; {'id': '18', 'type': 'if_statement', 'children': ['19', '24']}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '22'], 'value': 'or'}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'False', 'children': []}; {'id': '27', 'type': 'if_statement', 'children': ['28', '37']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '33'], 'value': '!='}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '37', 'type': 'block', 'children': ['38', '55']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '__Log__'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '%'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'DiffArrayObjects: Array lengths do not match %d != %d'"}; {'id': '46', 'type': 'tuple', 'children': ['47', '51']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'False', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'firstObj'}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '68', '77', '95', '113']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'IsPrimitiveType'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'firstObj'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'DiffPrimitiveArrays'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '77', 'type': 'elif_clause', 'children': ['78', '85']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'firstObj'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'ManagedObject'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'DiffAnyArrays'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93', '94']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'isElementLinks'}; {'id': '95', 'type': 'elif_clause', 'children': ['96', '103']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'firstObj'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'DataObject'}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'DiffDoArrays'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111', '112']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'newObj'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'isElementLinks'}; {'id': '113', 'type': 'else_clause', 'children': ['114']}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'raise_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '121'], 'value': '%'}; {'id': '120', 'type': 'string', 'children': [], 'value': '"Unknown type: %s"'}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'oldObj'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': '__class__'}
|
Method which deligates the diffing of arrays based on the type
|
def plot_gaps(plot, columns):
from plot_window import window_plot_convolve as plot_window
plot_window([[100 - i for i in columns]], len(columns)*.01, plot)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_gaps'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '6', 'type': 'block', 'children': ['7', '14']}; {'id': '7', 'type': 'import_from_statement', 'children': ['8', '10']}; {'id': '8', 'type': 'dotted_name', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'plot_window'}; {'id': '10', 'type': 'aliased_import', 'children': ['11', '13']}; {'id': '11', 'type': 'dotted_name', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'window_plot_convolve'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'plot_window'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'plot_window'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '26', '32']}; {'id': '18', 'type': 'list', 'children': ['19'], 'value': '[[100 - i for i in columns]]'}; {'id': '19', 'type': 'list_comprehension', 'children': ['20', '23']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '-'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '23', 'type': 'for_in_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '31'], 'value': '*'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '31', 'type': 'float', 'children': [], 'value': '.01'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'plot'}
|
plot % of gaps at each position
|
def getMouse(self):
self.mouse_x.value = -1
self.mouse_y.value = -1
while self.mouse_x.value == -1 and self.mouse_y.value == -1:
time.sleep(.1)
return (self.mouse_x.value, self.mouse_y.value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getMouse'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '24', '50']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'mouse_x'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'unary_operator', 'children': ['14'], 'value': '-'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'mouse_y'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '22', 'type': 'unary_operator', 'children': ['23'], 'value': '-'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '24', 'type': 'while_statement', 'children': ['25', '42']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '34'], 'value': 'and'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '32'], 'value': '=='}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'mouse_x'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '32', 'type': 'unary_operator', 'children': ['33'], 'value': '-'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '40'], 'value': '=='}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'mouse_y'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '40', 'type': 'unary_operator', 'children': ['41'], 'value': '-'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'float', 'children': [], 'value': '.1'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'tuple', 'children': ['52', '57']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'mouse_x'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'mouse_y'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Waits for a mouse click.
|
def _split_string_to_tokens(text):
if not text:
return []
ret = []
token_start = 0
is_alnum = [c in _ALPHANUMERIC_CHAR_SET for c in text]
for pos in xrange(1, len(text)):
if is_alnum[pos] != is_alnum[pos - 1]:
token = text[token_start:pos]
if token != u" " or token_start == 0:
ret.append(token)
token_start = pos
final_token = text[token_start:]
ret.append(final_token)
return ret
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_split_string_to_tokens'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '16', '20', '30', '81', '89', '96']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '15', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'token_start'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'is_alnum'}; {'id': '23', 'type': 'list_comprehension', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'in'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_ALPHANUMERIC_CHAR_SET'}; {'id': '27', 'type': 'for_in_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '40']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '51']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '46'], 'value': '!='}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'is_alnum'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'is_alnum'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '-'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '51', 'type': 'block', 'children': ['52', '61', '77']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '57', 'type': 'slice', 'children': ['58', '59', '60']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'token_start'}; {'id': '59', 'type': 'colon', 'children': []}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '69']}; {'id': '62', 'type': 'boolean_operator', 'children': ['63', '66'], 'value': 'or'}; {'id': '63', 'type': 'comparison_operator', 'children': ['64', '65'], 'value': '!='}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '65', 'type': 'string', 'children': [], 'value': 'u" "'}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '68'], 'value': '=='}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'token_start'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'token_start'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'final_token'}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '86', 'type': 'slice', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'token_start'}; {'id': '88', 'type': 'colon', 'children': []}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'final_token'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'ret'}
|
Splits text to a list of string tokens.
|
def handle_pubrel(self):
self.logger.info("PUBREL received")
ret, mid = self.in_packet.read_uint16()
if ret != NC.ERR_SUCCESS:
return ret
evt = event.EventPubrel(mid)
self.push_event(evt)
return NC.ERR_SUCCESS
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_pubrel'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '27', '36', '45', '52']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"PUBREL received"'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'mid'}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'in_packet'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'read_uint16'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'if_statement', 'children': ['28', '33']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': '!='}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'NC'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ERR_SUCCESS'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'evt'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'EventPubrel'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'mid'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'push_event'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'evt'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'NC'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ERR_SUCCESS'}
|
Handle incoming PUBREL packet.
|
def detach(self):
if not self._closed:
del self._as_parameter_
self._closed = True
self._ptr = None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'detach'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_closed'}; {'id': '11', 'type': 'block', 'children': ['12', '16', '22']}; {'id': '12', 'type': 'delete_statement', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_as_parameter_'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_closed'}; {'id': '21', 'type': 'True', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_ptr'}; {'id': '27', 'type': 'None', 'children': []}
|
Detach the underlying LLVM resource without disposing of it.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.