code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def _get_signature(self, entry): if self._sha1_sigs: if not os.path.exists(entry.filename): return None try: with open(entry.filename, "r") as f: data = f.read() return hashlib.sha1(data.encode("utf-8")).digest() except IOError as e: print("Cannot determine sha1 digest:", e) return None else: try: return os.path.getmtime(entry.filename) except OSError: return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_signature'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11', '81']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_sha1_sigs'}; {'id': '11', 'type': 'block', 'children': ['12', '27']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '24']}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'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': 'os'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'try_statement', 'children': ['28', '67']}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'with_statement', 'children': ['30', '42']}; {'id': '30', 'type': 'with_clause', 'children': ['31']}; {'id': '31', 'type': 'with_item', 'children': ['32']}; {'id': '32', 'type': 'as_pattern', 'children': ['33', '40']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"r"'}; {'id': '40', 'type': 'as_pattern_target', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '42', 'type': 'block', 'children': ['43', '51']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '66']}; {'id': '53', 'type': 'attribute', 'children': ['54', '65']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sha1'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'digest'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'except_clause', 'children': ['68', '72']}; {'id': '68', 'type': 'as_pattern', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '70', 'type': 'as_pattern_target', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '72', 'type': 'block', 'children': ['73', '79']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': '"Cannot determine sha1 digest:"'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'None', 'children': []}; {'id': '81', 'type': 'else_clause', 'children': ['82']}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'try_statement', 'children': ['84', '96']}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '92']}; {'id': '87', 'type': 'attribute', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'getmtime'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '96', 'type': 'except_clause', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'return_statement', 'children': ['100']}; {'id': '100', 'type': 'None', 'children': []}
Return the signature of the file stored in entry.
def length(self): return sum([shot.length for shot in self.shots if not shot.is_splay])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'length'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '14', '19']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'shot'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '14', 'type': 'for_in_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'shot'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'shots'}; {'id': '19', 'type': 'if_clause', 'children': ['20']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'shot'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'is_splay'}
Total surveyed cave length, not including splays.
def close_connection (self): if self.url_connection is not None: try: self.url_connection.quit() except Exception: pass self.url_connection = None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close_connection'}; {'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']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is not'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'url_connection'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '27']}; {'id': '13', 'type': 'try_statement', 'children': ['14', '23']}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'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': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'url_connection'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'quit'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'except_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'pass_statement', 'children': []}; {'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': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'url_connection'}; {'id': '32', 'type': 'None', 'children': []}
Release the open connection from the connection pool.
def run_actor(self, actor): set_actor(actor) if not actor.mailbox.address: address = ('127.0.0.1', 0) actor._loop.create_task( actor.mailbox.start_serving(address=address) ) actor._loop.run_forever()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_actor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '6', 'type': 'block', 'children': ['7', '12', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'set_actor'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '19']}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'mailbox'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '19', 'type': 'block', 'children': ['20', '26']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'127.0.0.1'"}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'expression_statement', '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': 'actor'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_loop'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'create_task'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'mailbox'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'start_serving'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_loop'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'run_forever'}; {'id': '51', 'type': 'argument_list', 'children': []}
Start running the ``actor``.
def as_dict(self): "Get the WorkResult as a dict." return { 'output': self.output, 'test_outcome': self.test_outcome, 'worker_outcome': self.worker_outcome, 'diff': self.diff, }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Get the WorkResult as a dict."'}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'dictionary', 'children': ['10', '15', '20', '25']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'output'"}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'test_outcome'"}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'test_outcome'}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'worker_outcome'"}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'worker_outcome'}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'diff'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'diff'}
Get the WorkResult as a dict.
def encode(value, encoding='utf-8', encoding_errors='strict'): if isinstance(value, bytes): return value if not isinstance(value, basestring): value = str(value) if isinstance(value, unicode): value = value.encode(encoding, encoding_errors) return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'encoding_errors'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'strict'"}; {'id': '11', 'type': 'block', 'children': ['12', '21', '36', '53']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'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': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'basestring'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '42']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'encoding_errors'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'value'}
Return a bytestring representation of the value.
def function_end(self): self.newline_label(self.shared.function_name + "_exit", True, True) self.move("%14", "%15") self.pop("%14") self.newline_text("RET", True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'function_end'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21', '29', '36']}; {'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': 'newline_label'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '19', '20']}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '18'], 'value': '+'}; {'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': 'shared'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'function_name'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"_exit"'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'True', 'children': []}; {'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': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'move'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"%14"'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"%15"'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"%14"'}; {'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': 'newline_text'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"RET"'}; {'id': '43', 'type': 'True', 'children': []}
Inserts an exit label and function return instructions
def param_dict_to_list(dict,skeys=None): RV = SP.concatenate([dict[key].flatten() for key in skeys]) return RV pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'param_dict_to_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'skeys'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '28', '30']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'RV'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'SP'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'concatenate'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'list_comprehension', 'children': ['18', '25']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'skeys'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'RV'}; {'id': '30', 'type': 'pass_statement', 'children': []}
convert from param dictionary to list
def render_registration(self): surface = self.get_surface() if self.canvas is None or self.df_canvas_corners.shape[0] == 0: return surface corners = self.df_canvas_corners.copy() corners['w'] = 1 transform = self.canvas.shapes_to_canvas_transform canvas_corners = corners.values.dot(transform.T.values).T points_x = canvas_corners[0] points_y = canvas_corners[1] cairo_context = cairo.Context(surface) cairo_context.move_to(points_x[0], points_y[0]) for x, y in zip(points_x[1:], points_y[1:]): cairo_context.line_to(x, y) cairo_context.line_to(points_x[0], points_y[0]) cairo_context.set_source_rgb(1, 0, 0) cairo_context.stroke() return surface
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_registration'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '33', '43', '49', '57', '74', '80', '86', '95', '107', '133', '145', '154', '160']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'surface'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_surface'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '30']}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '21'], 'value': 'or'}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': 'is'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'canvas'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '29'], 'value': '=='}; {'id': '22', 'type': 'subscript', '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': 'df_canvas_corners'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'surface'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'corners'}; {'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': 'df_canvas_corners'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'corners'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'transform'}; {'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': 'canvas'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'shapes_to_canvas_transform'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'canvas_corners'}; {'id': '60', 'type': 'attribute', 'children': ['61', '73']}; {'id': '61', 'type': 'call', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'corners'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'dot'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'transform'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'points_x'}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'canvas_corners'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'points_y'}; {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'canvas_corners'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'cairo_context'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'cairo'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'Context'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'surface'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'cairo_context'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'move_to'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '104']}; {'id': '101', 'type': 'subscript', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'points_x'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '104', 'type': 'subscript', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'points_y'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '107', 'type': 'for_statement', 'children': ['108', '111', '124']}; {'id': '108', 'type': 'pattern_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '119']}; {'id': '114', 'type': 'subscript', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'points_x'}; {'id': '116', 'type': 'slice', 'children': ['117', '118']}; {'id': '117', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '118', 'type': 'colon', 'children': []}; {'id': '119', 'type': 'subscript', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'points_y'}; {'id': '121', 'type': 'slice', 'children': ['122', '123']}; {'id': '122', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '123', 'type': 'colon', 'children': []}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'cairo_context'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'line_to'}; {'id': '130', 'type': 'argument_list', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'cairo_context'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'line_to'}; {'id': '138', 'type': 'argument_list', 'children': ['139', '142']}; {'id': '139', 'type': 'subscript', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'points_x'}; {'id': '141', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '142', 'type': 'subscript', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'points_y'}; {'id': '144', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'cairo_context'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'set_source_rgb'}; {'id': '150', 'type': 'argument_list', 'children': ['151', '152', '153']}; {'id': '151', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '152', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '153', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}; {'id': '155', 'type': 'call', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'cairo_context'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'stroke'}; {'id': '159', 'type': 'argument_list', 'children': []}; {'id': '160', 'type': 'return_statement', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'surface'}
Render pinned points on video frame as red rectangle.
def fileserver(opts, backends): return LazyLoader(_module_dirs(opts, 'fileserver'), opts, tag='fileserver', whitelist=backends, pack={'__utils__': utils(opts)})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fileserver'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'backends'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'LazyLoader'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '16', '17', '20', '23']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_module_dirs'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'fileserver'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'fileserver'"}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'whitelist'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'backends'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '25', 'type': 'dictionary', 'children': ['26']}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'__utils__'"}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'opts'}
Returns the file server modules
def on_batch_begin(self, train, **kwargs:Any)->None: "Record learning rate and momentum at beginning of batch." if train: self.lrs.append(self.opt.lr) self.moms.append(self.opt.mom)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_batch_begin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'train'}; {'id': '6', 'type': 'typed_parameter', 'children': ['7', '9']}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Any'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '16']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"Record learning rate and momentum at beginning of batch."'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'train'}; {'id': '18', 'type': 'block', 'children': ['19', '32']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'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': 'lrs'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'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': 'opt'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'lr'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'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': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'moms'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'mom'}
Record learning rate and momentum at beginning of batch.
def precheck(): cfg_path = local_config['PROJECT']['CONFIG_PATH'] logging = set_logging(local_config) if os.path.exists(cfg_path): logger.info('%s: config_path parameter: %s' % (inspect.stack()[0][3], cfg_path)) logger.info( '%s: Existing configuration file found. precheck pass.' % (inspect.stack()[0][3])) return True elif not os.path.exists(cfg_path) and logging is False: logger.info( '%s: No pre-existing configuration file found at %s. Using defaults. Logging disabled.' % (inspect.stack()[0][3], cfg_path) ) return True if logging: logger.info( '%s: Logging enabled per config file (%s).' % (inspect.stack()[0][3], cfg_path) ) return True return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'precheck'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '20', '105', '129']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cfg_path'}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'local_config'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'PROJECT'"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'CONFIG_PATH'"}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'set_logging'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'local_config'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '29', '69']}; {'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': 'os'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cfg_path'}; {'id': '29', 'type': 'block', 'children': ['30', '49', '67']}; {'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': 'logger'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '%'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'%s: config_path parameter: %s'"}; {'id': '38', 'type': 'tuple', 'children': ['39', '48']}; {'id': '39', 'type': 'subscript', 'children': ['40', '47']}; {'id': '40', 'type': 'subscript', 'children': ['41', '46']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'stack'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cfg_path'}; {'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': 'logger'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '%'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'%s: Existing configuration file found. precheck pass.'"}; {'id': '57', 'type': '()', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '66']}; {'id': '59', 'type': 'subscript', 'children': ['60', '65']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'stack'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'True', 'children': []}; {'id': '69', 'type': 'elif_clause', 'children': ['70', '83']}; {'id': '70', 'type': 'boolean_operator', 'children': ['71', '80'], 'value': 'and'}; {'id': '71', 'type': 'not_operator', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '78']}; {'id': '73', 'type': 'attribute', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'cfg_path'}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'is'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '82', 'type': 'False', 'children': []}; {'id': '83', 'type': 'block', 'children': ['84', '103']}; {'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': 'logger'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '92'], 'value': '%'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'%s: No pre-existing configuration file found at %s. Using defaults. Logging disabled.'"}; {'id': '92', 'type': 'tuple', 'children': ['93', '102']}; {'id': '93', 'type': 'subscript', 'children': ['94', '101']}; {'id': '94', 'type': 'subscript', 'children': ['95', '100']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'stack'}; {'id': '99', 'type': 'argument_list', 'children': []}; {'id': '100', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'cfg_path'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'True', 'children': []}; {'id': '105', 'type': 'if_statement', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '107', 'type': 'block', 'children': ['108', '127']}; {'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': 'logger'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'binary_operator', 'children': ['115', '116'], 'value': '%'}; {'id': '115', 'type': 'string', 'children': [], 'value': "'%s: Logging enabled per config file (%s).'"}; {'id': '116', 'type': 'tuple', 'children': ['117', '126']}; {'id': '117', 'type': 'subscript', 'children': ['118', '125']}; {'id': '118', 'type': 'subscript', 'children': ['119', '124']}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'stack'}; {'id': '123', 'type': 'argument_list', 'children': []}; {'id': '124', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '125', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'cfg_path'}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'True', 'children': []}; {'id': '129', 'type': 'return_statement', 'children': ['130']}; {'id': '130', 'type': 'False', 'children': []}
Verify project runtime dependencies
def add_dependency(self, value): if value.name in self.dependencies: self.dependencies[value.name.lower()].append(value) else: self.dependencies[value.name.lower()] = [ value ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_dependency'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15', '33']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'in'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dependencies'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '31']}; {'id': '18', 'type': 'attribute', 'children': ['19', '30']}; {'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': 'dependencies'}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'else_clause', 'children': ['34']}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '48']}; {'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': 'dependencies'}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'list', 'children': ['49'], 'value': '[ value ]'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'value'}
Adds the specified executable dependency to the list for this executable.
def NoCache(self, *targets): tlist = [] for t in targets: tlist.extend(self.arg2nodes(t, self.fs.Entry)) for t in tlist: t.set_nocache() return tlist
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'NoCache'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '33', '43']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'tlist'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'for_statement', 'children': ['13', '14', '15']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'targets'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'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': 'tlist'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'arg2nodes'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fs'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'Entry'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'tlist'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'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': 't'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'set_nocache'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'tlist'}
Tags a target so that it will not be cached
def parse_field(source, loc, tokens): name = tokens[0].lower() value = normalize_value(tokens[2]) if name == 'author' and ' and ' in value: value = [field.strip() for field in value.split(' and ')] return (name, value)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '27', '53']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'subscript', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'normalize_value'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '35']}; {'id': '28', 'type': 'boolean_operator', 'children': ['29', '32'], 'value': 'and'}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'author'"}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'in'}; {'id': '33', 'type': 'string', 'children': [], 'value': "' and '"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'value'}; {'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': 'value'}; {'id': '39', 'type': 'list_comprehension', 'children': ['40', '45']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'for_in_clause', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': "' and '"}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'tuple', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'value'}
Returns the tokens of a field as key-value pair.
def writeln(self, text, fg='black', bg='white'): if not isinstance(text, str): text = str(text) self.write(text + '\n', fg=fg, bg=bg)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'writeln'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'black'"}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'bg'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'white'"}; {'id': '12', 'type': 'block', 'children': ['13', '28']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '20']}; {'id': '14', 'type': 'not_operator', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'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': 'text'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'text'}; {'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': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37', '40']}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '+'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'bg'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'bg'}
write to the console with linefeed
def send_keys(self, keyserver, *keyids): result = self._result_map['list'](self) log.debug('send_keys: %r', keyids) data = _util._make_binary_stream("", self._encoding) args = ['--keyserver', keyserver, '--send-keys'] args.extend(keyids) self._handle_io(args, data, result, binary=True) log.debug('send_keys result: %r', result.__dict__) data.close() return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_keys'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'keyserver'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'keyids'}; {'id': '8', 'type': 'block', 'children': ['9', '20', '28', '40', '47', '54', '66', '76', '82']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'subscript', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_result_map'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'list'"}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'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': 'log'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'send_keys: %r'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'keyids'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_util'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_make_binary_stream'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '""'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_encoding'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '43', 'type': 'list', 'children': ['44', '45', '46'], 'value': "['--keyserver', keyserver, '--send-keys']"}; {'id': '44', 'type': 'string', 'children': [], 'value': "'--keyserver'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'keyserver'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'--send-keys'"}; {'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': 'args'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'keyids'}; {'id': '54', 'type': 'expression_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': '_handle_io'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62', '63']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'binary'}; {'id': '65', 'type': 'True', 'children': []}; {'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': 'log'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'send_keys result: %r'"}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'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': 'data'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'result'}
Send keys to a keyserver.
def to_det_id(self, det_id_or_det_oid): try: int(det_id_or_det_oid) except ValueError: return self.get_det_id(det_id_or_det_oid) else: return det_id_or_det_oid
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_det_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'det_id_or_det_oid'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '14', '24']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'det_id_or_det_oid'}; {'id': '14', 'type': 'except_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'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_det_id'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'det_id_or_det_oid'}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'det_id_or_det_oid'}
Convert det ID or OID to det ID
def pack_value(self, val): if isinstance(val, bytes): val = list(iterbytes(val)) slen = len(val) if self.pad: pad = b'\0\0' * (slen % 2) else: pad = b'' return struct.pack('>' + 'H' * slen, *val) + pad, slen, None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pack_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '6', 'type': 'block', 'children': ['7', '24', '31', '51']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'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': 'val'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'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': 'val'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'iterbytes'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'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': 'val'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '35', '45']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pad'}; {'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': 'pad'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '*'}; {'id': '40', 'type': 'string', 'children': [], 'value': "b'\\0\\0'"}; {'id': '41', 'type': '()', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '%'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pad'}; {'id': '50', 'type': 'string', 'children': [], 'value': "b''"}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'expression_list', 'children': ['53', '67', '68']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '66'], 'value': '+'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '64']}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '+'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'>'"}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '*'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'H'"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'id': '64', 'type': 'list_splat', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'pad'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'id': '68', 'type': 'None', 'children': []}
Convert 8-byte string into 16-byte list
def builds(self, confs): self._named_builds = {} self._builds = [] for values in confs: if len(values) == 2: self._builds.append(BuildConf(values[0], values[1], {}, {}, self.reference)) elif len(values) == 4: self._builds.append(BuildConf(values[0], values[1], values[2], values[3], self.reference)) elif len(values) != 5: raise Exception("Invalid build configuration, has to be a tuple of " "(settings, options, env_vars, build_requires, reference)") else: self._builds.append(BuildConf(*values))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'builds'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'confs'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_named_builds'}; {'id': '12', 'type': 'dictionary', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_builds'}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'confs'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '30', '53', '87', '102']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '29'], 'value': '=='}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_builds'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'BuildConf'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '45', '48', '49', '50']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'dictionary', 'children': []}; {'id': '49', 'type': 'dictionary', 'children': []}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'reference'}; {'id': '53', 'type': 'elif_clause', 'children': ['54', '60']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '59'], 'value': '=='}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_builds'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'BuildConf'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '75', '78', '81', '84']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'reference'}; {'id': '87', 'type': 'elif_clause', 'children': ['88', '94']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '93'], 'value': '!='}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'raise_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'concatenated_string', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': '"Invalid build configuration, has to be a tuple of "'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"(settings, options, env_vars, build_requires, reference)"'}; {'id': '102', 'type': 'else_clause', 'children': ['103']}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '111']}; {'id': '106', 'type': 'attribute', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '_builds'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'BuildConf'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'list_splat', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'values'}
For retro compatibility directly assigning builds
def _svg_path(self, pathcodes, data): def gen_path_elements(pathcodes, data): counts = {'M': 1, 'L': 1, 'C': 3, 'Z': 0} it = iter(data) for code in pathcodes: yield code for _ in range(counts[code]): p = next(it) yield str(p[0]) yield str(p[1]) return ' '.join(gen_path_elements(pathcodes, data))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_svg_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pathcodes'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '7', 'type': 'block', 'children': ['8', '76']}; {'id': '8', 'type': 'function_definition', 'children': ['9', '10', '13']}; {'id': '9', 'type': 'function_name', 'children': [], 'value': 'gen_path_elements'}; {'id': '10', 'type': 'parameters', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pathcodes'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '13', 'type': 'block', 'children': ['14', '30', '37']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '17', 'type': 'dictionary', 'children': ['18', '21', '24', '27']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'M'"}; {'id': '20', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'L'"}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'C'"}; {'id': '26', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'Z'"}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'pathcodes'}; {'id': '40', 'type': 'block', 'children': ['41', '44']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'yield', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '52']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '52', 'type': 'block', 'children': ['53', '60', '68']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'yield', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'yield', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'gen_path_elements'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'pathcodes'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'data'}
Return the SVG path's 'd' element.
def getStats(jobStore): def aggregateStats(fileHandle,aggregateObject): try: stats = json.load(fileHandle, object_hook=Expando) for key in list(stats.keys()): if key in aggregateObject: aggregateObject[key].append(stats[key]) else: aggregateObject[key]=[stats[key]] except ValueError: logger.critical("File %s contains corrupted json. Skipping file." % fileHandle) pass aggregateObject = Expando() callBack = partial(aggregateStats, aggregateObject=aggregateObject) jobStore.readStatsAndLogging(callBack, readAll=True) return aggregateObject
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getStats'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'jobStore'}; {'id': '5', 'type': 'block', 'children': ['6', '77', '83', '93', '103']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'aggregateStats'}; {'id': '8', 'type': 'parameters', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fileHandle'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'aggregateObject'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'try_statement', 'children': ['13', '64']}; {'id': '13', 'type': 'block', 'children': ['14', '26']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fileHandle'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'object_hook'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Expando'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '36']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '41', '53']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': 'in'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'aggregateObject'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'aggregateObject'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '53', 'type': 'else_clause', 'children': ['54']}; {'id': '54', 'type': 'block', 'children': ['55']}; {'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': 'aggregateObject'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '60', 'type': 'list', 'children': ['61'], 'value': '[stats[key]]'}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '64', 'type': 'except_clause', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '66', 'type': 'block', 'children': ['67', '76']}; {'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': 'logger'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'critical'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '75'], 'value': '%'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"File %s contains corrupted json. Skipping file."'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'fileHandle'}; {'id': '76', 'type': 'pass_statement', 'children': []}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'aggregateObject'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'Expando'}; {'id': '82', 'type': 'argument_list', 'children': []}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'callBack'}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'aggregateStats'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'aggregateObject'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'aggregateObject'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'jobStore'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'readStatsAndLogging'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'callBack'}; {'id': '100', 'type': 'keyword_argument', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'readAll'}; {'id': '102', 'type': 'True', 'children': []}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'aggregateObject'}
Collect and return the stats and config data.
def _register_data_plane_account_arguments(self, command_name): from azure.cli.core.commands.parameters import get_resource_name_completion_list from ._validators import validate_client_parameters command = self.command_loader.command_table.get(command_name, None) if not command: return group_name = 'Storage Account' command.add_argument('account_name', '--account-name', required=False, default=None, arg_group=group_name, completer=get_resource_name_completion_list('Microsoft.Storage/storageAccounts'), help='Storage account name. Related environment variable: AZURE_STORAGE_ACCOUNT. Must be ' 'used in conjunction with either storage account key or a SAS token. If neither are ' 'present, the command will try to query the storage account key using the ' 'authenticated Azure account. If a large number of storage commands are executed the ' 'API quota may be hit') command.add_argument('account_key', '--account-key', required=False, default=None, arg_group=group_name, help='Storage account key. Must be used in conjunction with storage account name. ' 'Environment variable: AZURE_STORAGE_KEY') command.add_argument('connection_string', '--connection-string', required=False, default=None, validator=validate_client_parameters, arg_group=group_name, help='Storage account connection string. Environment variable: ' 'AZURE_STORAGE_CONNECTION_STRING') command.add_argument('sas_token', '--sas-token', required=False, default=None, arg_group=group_name, help='A Shared Access Signature (SAS). Must be used in conjunction with storage account ' 'name. Environment variable: AZURE_STORAGE_SAS_TOKEN')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_register_data_plane_account_arguments'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'command_name'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '23', '37', '42', '46', '77', '99', '124']}; {'id': '7', 'type': 'import_from_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'dotted_name', 'children': ['9', '10', '11', '12', '13']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'azure'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cli'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'parameters'}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get_resource_name_completion_list'}; {'id': '16', 'type': 'import_from_statement', 'children': ['17', '21']}; {'id': '17', 'type': 'relative_import', 'children': ['18', '19']}; {'id': '18', 'type': 'import_prefix', 'children': []}; {'id': '19', 'type': 'dotted_name', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_validators'}; {'id': '21', 'type': 'dotted_name', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'validate_client_parameters'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '26', 'type': 'call', 'children': ['27', '34']}; {'id': '27', 'type': 'attribute', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'command_loader'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'command_table'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'command_name'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'if_statement', 'children': ['38', '40']}; {'id': '38', 'type': 'not_operator', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'return_statement', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'Storage Account'"}; {'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': 'command'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53', '54', '57', '60', '63', '69']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'account_name'"}; {'id': '53', 'type': 'string', 'children': [], 'value': "'--account-name'"}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '56', 'type': 'False', 'children': []}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '59', 'type': 'None', 'children': []}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'arg_group'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'completer'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'get_resource_name_completion_list'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'string', 'children': [], 'value': "'Microsoft.Storage/storageAccounts'"}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '71', 'type': 'concatenated_string', 'children': ['72', '73', '74', '75', '76']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'Storage account name. Related environment variable: AZURE_STORAGE_ACCOUNT. Must be '"}; {'id': '73', 'type': 'string', 'children': [], 'value': "'used in conjunction with either storage account key or a SAS token. If neither are '"}; {'id': '74', 'type': 'string', 'children': [], 'value': "'present, the command will try to query the storage account key using the '"}; {'id': '75', 'type': 'string', 'children': [], 'value': "'authenticated Azure account. If a large number of storage commands are executed the '"}; {'id': '76', 'type': 'string', 'children': [], 'value': "'API quota may be hit'"}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84', '85', '88', '91', '94']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'account_key'"}; {'id': '84', 'type': 'string', 'children': [], 'value': "'--account-key'"}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '87', 'type': 'False', 'children': []}; {'id': '88', 'type': 'keyword_argument', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '90', 'type': 'None', 'children': []}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'arg_group'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '94', 'type': 'keyword_argument', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '96', 'type': 'concatenated_string', 'children': ['97', '98']}; {'id': '97', 'type': 'string', 'children': [], 'value': "'Storage account key. Must be used in conjunction with storage account name. '"}; {'id': '98', 'type': 'string', 'children': [], 'value': "'Environment variable: AZURE_STORAGE_KEY'"}; {'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': 'command'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106', '107', '110', '113', '116', '119']}; {'id': '105', 'type': 'string', 'children': [], 'value': "'connection_string'"}; {'id': '106', 'type': 'string', 'children': [], 'value': "'--connection-string'"}; {'id': '107', 'type': 'keyword_argument', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '109', 'type': 'False', 'children': []}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '112', 'type': 'None', 'children': []}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'validator'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'validate_client_parameters'}; {'id': '116', 'type': 'keyword_argument', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'arg_group'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '119', 'type': 'keyword_argument', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '121', 'type': 'concatenated_string', 'children': ['122', '123']}; {'id': '122', 'type': 'string', 'children': [], 'value': "'Storage account connection string. Environment variable: '"}; {'id': '123', 'type': 'string', 'children': [], 'value': "'AZURE_STORAGE_CONNECTION_STRING'"}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '131', '132', '135', '138', '141']}; {'id': '130', 'type': 'string', 'children': [], 'value': "'sas_token'"}; {'id': '131', 'type': 'string', 'children': [], 'value': "'--sas-token'"}; {'id': '132', 'type': 'keyword_argument', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '134', 'type': 'False', 'children': []}; {'id': '135', 'type': 'keyword_argument', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '137', 'type': 'None', 'children': []}; {'id': '138', 'type': 'keyword_argument', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'arg_group'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '141', 'type': 'keyword_argument', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '143', 'type': 'concatenated_string', 'children': ['144', '145']}; {'id': '144', 'type': 'string', 'children': [], 'value': "'A Shared Access Signature (SAS). Must be used in conjunction with storage account '"}; {'id': '145', 'type': 'string', 'children': [], 'value': "'name. Environment variable: AZURE_STORAGE_SAS_TOKEN'"}
Add parameters required to create a storage client
def _new_sample(self, sink): if self.running: buf = sink.emit('pull-sample').get_buffer() mem = buf.get_all_memory() success, info = mem.map(Gst.MapFlags.READ) if success: data = info.data mem.unmap(info) self.queue.put(data) else: raise GStreamerError("Unable to map buffer memory while reading the file.") return Gst.FlowReturn.OK
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_new_sample'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sink'}; {'id': '6', 'type': 'block', 'children': ['7', '80']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'running'}; {'id': '11', 'type': 'block', 'children': ['12', '25', '33', '48']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '15', 'type': 'call', 'children': ['16', '24']}; {'id': '16', 'type': 'attribute', 'children': ['17', '23']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sink'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'emit'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'pull-sample'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_buffer'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'mem'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get_all_memory'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'mem'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Gst'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'MapFlags'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'READ'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '50', '73']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '50', 'type': 'block', 'children': ['51', '57', '64']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'mem'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'unmap'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '73', 'type': 'else_clause', 'children': ['74']}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'raise_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'GStreamerError'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"Unable to map buffer memory while reading the file."'}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'attribute', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Gst'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'FlowReturn'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'OK'}
The callback for appsink's "new-sample" signal.
def pid_from_context(_, context): pid = (context or {}).get('pid') return pid.pid_value if pid else missing
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pid_from_context'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '10', 'type': 'call', 'children': ['11', '17']}; {'id': '11', 'type': 'attribute', 'children': ['12', '16']}; {'id': '12', 'type': '()', 'children': ['13']}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '15'], 'value': 'or'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '15', 'type': 'dictionary', 'children': []}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'pid'"}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'conditional_expression', 'children': ['21', '24', '25'], 'value': 'if'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pid_value'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'missing'}
Get PID from marshmallow context.
def path(self): if (self.source_file.startswith('a/') and self.target_file.startswith('b/')): filepath = self.source_file[2:] elif (self.source_file.startswith('a/') and self.target_file == '/dev/null'): filepath = self.source_file[2:] elif (self.target_file.startswith('b/') and self.source_file == '/dev/null'): filepath = self.target_file[2:] else: filepath = self.source_file return filepath
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '98']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '25', '36', '63', '90']}; {'id': '7', 'type': '()', 'children': ['8']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '17'], 'value': 'and'}; {'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': 'source_file'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'a/'"}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'target_file'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'b/'"}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '29', 'type': 'subscript', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '33', 'type': 'slice', 'children': ['34', '35']}; {'id': '34', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '35', 'type': 'colon', 'children': []}; {'id': '36', 'type': 'elif_clause', 'children': ['37', '52']}; {'id': '37', 'type': '()', 'children': ['38']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '47'], 'value': 'and'}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'a/'"}; {'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': 'target_file'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'/dev/null'"}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '56', 'type': 'subscript', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '60', 'type': 'slice', 'children': ['61', '62']}; {'id': '61', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '62', 'type': 'colon', 'children': []}; {'id': '63', 'type': 'elif_clause', 'children': ['64', '79']}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': 'boolean_operator', 'children': ['66', '74'], 'value': 'and'}; {'id': '66', 'type': 'call', 'children': ['67', '72']}; {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'target_file'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': "'b/'"}; {'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': 'source_file'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'/dev/null'"}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '83', 'type': 'subscript', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'target_file'}; {'id': '87', 'type': 'slice', 'children': ['88', '89']}; {'id': '88', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '89', 'type': 'colon', 'children': []}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'source_file'}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'filepath'}
Return the file path abstracted from VCS.
def DualDBFlow(cls): if issubclass(cls, flow.GRRFlow): raise ValueError("Mixin class shouldn't inherit from GRRFlow.") if cls.__name__[-5:] != "Mixin": raise ValueError("Flow mixin should have a name that ends in 'Mixin'.") flow_name = cls.__name__[:-5] aff4_cls = type(flow_name, (cls, flow.GRRFlow), {}) aff4_cls.__doc__ = cls.__doc__ setattr(aff4_flows, flow_name, aff4_cls) reldb_cls = type(flow_name, (cls, FlowBase), {}) reldb_cls.__doc__ = cls.__doc__ setattr(sys.modules[cls.__module__], flow_name, reldb_cls) return cls
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DualDBFlow'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '37', '48', '61', '69', '76', '87', '95', '108']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'issubclass'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'GRRFlow'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"Mixin class shouldn\'t inherit from GRRFlow."'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '31']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '30'], 'value': '!='}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '26', 'type': 'slice', 'children': ['27', '29']}; {'id': '27', 'type': 'unary_operator', 'children': ['28'], 'value': '-'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '29', 'type': 'colon', 'children': []}; {'id': '30', 'type': 'string', 'children': [], 'value': '"Mixin"'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'raise_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"Flow mixin should have a name that ends in \'Mixin\'."'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '44', 'type': 'slice', 'children': ['45', '46']}; {'id': '45', 'type': 'colon', 'children': []}; {'id': '46', 'type': 'unary_operator', 'children': ['47'], 'value': '-'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'aff4_cls'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '60']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '55', 'type': 'tuple', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'GRRFlow'}; {'id': '60', 'type': 'dictionary', 'children': []}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'aff4_cls'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74', '75']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'aff4_flows'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'aff4_cls'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'reldb_cls'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83', '86']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '83', 'type': 'tuple', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'FlowBase'}; {'id': '86', 'type': 'dictionary', 'children': []}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'reldb_cls'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '106', '107']}; {'id': '99', 'type': 'subscript', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': '__module__'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'reldb_cls'}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'cls'}
Decorator that creates AFF4 and RELDB flows from a given mixin.
def _get_ratings_page(self): self._build_url() soup = get_soup(self.url) if soup: return soup self._build_url(shorten=False) soup = get_soup(self.url) if soup: return soup return SearchDaily(self.category, date=self.date).fetch_result()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_ratings_page'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '21', '26', '35', '44', '49']}; {'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': '_build_url'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get_soup'}; {'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': 'url'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'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': '_build_url'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'shorten'}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get_soup'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '64']}; {'id': '51', 'type': 'attribute', 'children': ['52', '63']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'SearchDaily'}; {'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': 'category'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'fetch_result'}; {'id': '64', 'type': 'argument_list', 'children': []}
Do a limited search for the correct url.
def save(cls, filename, config): mode = os.O_WRONLY | os.O_TRUNC | os.O_CREAT with os.fdopen(os.open(filename, mode, 0o600), 'w') as fname: yaml.safe_dump(config, fname, indent=4, default_flow_style=False)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '7', 'type': 'block', 'children': ['8', '22']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '19'], 'value': '|'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '16'], 'value': '|'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'O_WRONLY'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'O_TRUNC'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'O_CREAT'}; {'id': '22', 'type': 'with_statement', 'children': ['23', '42']}; {'id': '23', 'type': 'with_clause', 'children': ['24']}; {'id': '24', 'type': 'with_item', 'children': ['25']}; {'id': '25', 'type': 'as_pattern', 'children': ['26', '40']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'fdopen'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '39']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0o600'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '40', 'type': 'as_pattern_target', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'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': 'yaml'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'safe_dump'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50', '51', '54']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'default_flow_style'}; {'id': '56', 'type': 'False', 'children': []}
Save configuration to yaml file.
def read_calibration( detx=None, det_id=None, from_file=False, det_id_table=None ): from km3pipe.calib import Calibration if not (detx or det_id or from_file): return None if detx is not None: return Calibration(filename=detx) if from_file: det_ids = np.unique(det_id_table) if len(det_ids) > 1: log.critical("Multiple detector IDs found in events.") det_id = det_ids[0] if det_id is not None: if det_id < 0: log.warning( "Negative detector ID found ({0}). This is a MC " "detector and cannot be retrieved from the DB.".format(det_id) ) return None return Calibration(det_id=det_id) return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_calibration'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'detx'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'from_file'}; {'id': '12', 'type': 'False', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'det_id_table'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '23', '34', '46', '79', '112']}; {'id': '17', 'type': 'import_from_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'dotted_name', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'km3pipe'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'calib'}; {'id': '21', 'type': 'dotted_name', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Calibration'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '31']}; {'id': '24', 'type': 'not_operator', 'children': ['25']}; {'id': '25', 'type': '()', 'children': ['26']}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '30'], 'value': 'or'}; {'id': '27', 'type': 'boolean_operator', 'children': ['28', '29'], 'value': 'or'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'detx'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'from_file'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'is not'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'detx'}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Calibration'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'detx'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'from_file'}; {'id': '48', 'type': 'block', 'children': ['49', '58', '73']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'det_ids'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'det_id_table'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '65']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '64'], 'value': '>'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'det_ids'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'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': 'log'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'critical'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'string', 'children': [], 'value': '"Multiple detector IDs found in events."'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'det_ids'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '79', 'type': 'if_statement', 'children': ['80', '83']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'is not'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '82', 'type': 'None', 'children': []}; {'id': '83', 'type': 'block', 'children': ['84', '105']}; {'id': '84', 'type': 'if_statement', 'children': ['85', '88']}; {'id': '85', 'type': 'comparison_operator', 'children': ['86', '87'], 'value': '<'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '88', 'type': 'block', 'children': ['89', '103']}; {'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': 'log'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '101']}; {'id': '96', 'type': 'attribute', 'children': ['97', '100']}; {'id': '97', 'type': 'concatenated_string', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': '"Negative detector ID found ({0}). This is a MC "'}; {'id': '99', 'type': 'string', 'children': [], 'value': '"detector and cannot be retrieved from the DB."'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'None', 'children': []}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'Calibration'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'keyword_argument', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'det_id'}; {'id': '112', 'type': 'return_statement', 'children': ['113']}; {'id': '113', 'type': 'None', 'children': []}
Retrive calibration from file, the DB.
def resolve(self,size, distribution): if not self.variablesize(): raise Exception("Can only resize patterns with * wildcards") nrofwildcards = 0 for x in self.sequence: if x == '*': nrofwildcards += 1 assert (len(distribution) == nrofwildcards) wildcardnr = 0 newsequence = [] for x in self.sequence: if x == '*': newsequence += [True] * distribution[wildcardnr] wildcardnr += 1 else: newsequence.append(x) d = { 'matchannotation':self.matchannotation, 'matchannotationset':self.matchannotationset, 'casesensitive':self.casesensitive } yield Pattern(*newsequence, **d )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'distribution'}; {'id': '7', 'type': 'block', 'children': ['8', '21', '25', '40', '48', '52', '56', '89', '108']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '15']}; {'id': '9', 'type': 'not_operator', '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': 'variablesize'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'raise_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Can only resize patterns with * wildcards"'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'nrofwildcards'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '30']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'if_statement', 'children': ['32', '35']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': '=='}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'augmented_assignment', 'children': ['38', '39'], 'value': '+='}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'nrofwildcards'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': 'assert_statement', 'children': ['41']}; {'id': '41', 'type': '()', 'children': ['42']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '47'], 'value': '=='}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'distribution'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'nrofwildcards'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'wildcardnr'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'newsequence'}; {'id': '55', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '56', 'type': 'for_statement', 'children': ['57', '58', '61']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'if_statement', 'children': ['63', '66', '80']}; {'id': '63', 'type': 'comparison_operator', 'children': ['64', '65'], 'value': '=='}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '66', 'type': 'block', 'children': ['67', '76']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'augmented_assignment', 'children': ['69', '70'], 'value': '+='}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'newsequence'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '73'], 'value': '*'}; {'id': '71', 'type': 'list', 'children': ['72'], 'value': '[True]'}; {'id': '72', 'type': 'True', 'children': []}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'distribution'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'wildcardnr'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'augmented_assignment', 'children': ['78', '79'], 'value': '+='}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'wildcardnr'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'else_clause', 'children': ['81']}; {'id': '81', 'type': 'block', 'children': ['82']}; {'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': 'newsequence'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '92', 'type': 'dictionary', 'children': ['93', '98', '103']}; {'id': '93', 'type': 'pair', 'children': ['94', '95']}; {'id': '94', 'type': 'string', 'children': [], 'value': "'matchannotation'"}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'matchannotation'}; {'id': '98', 'type': 'pair', 'children': ['99', '100']}; {'id': '99', 'type': 'string', 'children': [], 'value': "'matchannotationset'"}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'matchannotationset'}; {'id': '103', 'type': 'pair', 'children': ['104', '105']}; {'id': '104', 'type': 'string', 'children': [], 'value': "'casesensitive'"}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'casesensitive'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'yield', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'Pattern'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '115']}; {'id': '113', 'type': 'list_splat', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'newsequence'}; {'id': '115', 'type': 'dictionary_splat', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'd'}
Resolve a variable sized pattern to all patterns of a certain fixed size
def calculate_quality_metrics(metrics, designs, verbose=False): for metric in metrics: if metric.progress_update: print metric.progress_update metric.load(designs, verbose)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_quality_metrics'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'designs'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '13', 'type': 'block', 'children': ['14', '23']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'progress_update'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'print_statement', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'progress_update'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'designs'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'verbose'}
Have each metric calculate all the information it needs.
def make_compound_ctype(self, varname): compoundname = self.get_var_type(varname) nfields = self.inq_compound(compoundname) fields = [] for i in range(nfields): (fieldname, fieldtype, fieldrank, fieldshape) = self.inq_compound_field(compoundname, i) assert fieldrank <= 1 fieldctype = CTYPESMAP[fieldtype] if fieldrank == 1: fieldctype = fieldctype * fieldshape[0] fields.append((fieldname, fieldctype)) class COMPOUND(Structure): _fields_ = fields rank = self.get_var_rank(varname) assert rank <= 1, "we can't handle >=2 dimensional compounds yet" if rank == 1: shape = self.get_var_shape(varname) valtype = POINTER(ARRAY(COMPOUND, shape[0])) else: valtype = POINTER(COMPOUND) return valtype
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_compound_ctype'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '29', '82', '91', '100', '105', '141']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'compoundname'}; {'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': 'get_var_type'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'nfields'}; {'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': 'inq_compound'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'compoundname'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '28', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '35']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'nfields'}; {'id': '35', 'type': 'block', 'children': ['36', '50', '54', '60', '73']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '43']}; {'id': '38', 'type': 'tuple_pattern', 'children': ['39', '40', '41', '42']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'fieldname'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fieldtype'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fieldrank'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fieldshape'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'inq_compound_field'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'compoundname'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '50', 'type': 'assert_statement', 'children': ['51']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': '<='}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'fieldrank'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'fieldctype'}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'CTYPESMAP'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'fieldtype'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '64']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '63'], 'value': '=='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'fieldrank'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'fieldctype'}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '70'], 'value': '*'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'fieldctype'}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'fieldshape'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'tuple', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'fieldname'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'fieldctype'}; {'id': '82', 'type': 'class_definition', 'children': ['83', '84', '86']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'COMPOUND'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'Structure'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_fields_'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'rank'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'get_var_rank'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '100', 'type': 'assert_statement', 'children': ['101', '104']}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '103'], 'value': '<='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'rank'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'string', 'children': [], 'value': '"we can\'t handle >=2 dimensional compounds yet"'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '109', '132']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': '=='}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'rank'}; {'id': '108', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '109', 'type': 'block', 'children': ['110', '119']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'get_var_shape'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'valtype'}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'POINTER'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'ARRAY'}; {'id': '127', 'type': 'argument_list', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'COMPOUND'}; {'id': '129', 'type': 'subscript', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '131', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '132', 'type': 'else_clause', 'children': ['133']}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'valtype'}; {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'POINTER'}; {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'COMPOUND'}; {'id': '141', 'type': 'return_statement', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'valtype'}
Create a ctypes type that corresponds to a compound type in memory.
def _fetch_metric(self, metric_name): request = { 'Namespace': self.CLOUDWATCH_NAMESPACE, 'MetricName': metric_name, 'Dimensions': [ { 'Name': 'TrainingJobName', 'Value': self.name } ], 'StartTime': self._time_interval['start_time'], 'EndTime': self._time_interval['end_time'], 'Period': self._period, 'Statistics': ['Average'], } raw_cwm_data = self._cloudwatch.get_metric_statistics(**request)['Datapoints'] if len(raw_cwm_data) == 0: logging.warning("Warning: No metrics called %s found" % metric_name) return base_time = min(raw_cwm_data, key=lambda pt: pt['Timestamp'])['Timestamp'] all_xy = [] for pt in raw_cwm_data: y = pt['Average'] x = (pt['Timestamp'] - base_time).total_seconds() all_xy.append([x, y]) all_xy = sorted(all_xy, key=lambda x: x[0]) for elapsed_seconds, value in all_xy: self._add_single_metric(elapsed_seconds, metric_name, value)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fetch_metric'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'metric_name'}; {'id': '6', 'type': 'block', 'children': ['7', '54', '68', '86', '103', '107', '139', '154']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '10', 'type': 'dictionary', 'children': ['11', '16', '19', '31', '38', '45', '50']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'Namespace'"}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'CLOUDWATCH_NAMESPACE'}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'MetricName'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'metric_name'}; {'id': '19', 'type': 'pair', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'Dimensions'"}; {'id': '21', 'type': 'list', 'children': ['22'], 'value': "[\n {\n 'Name': 'TrainingJobName',\n 'Value': self.name\n }\n ]"}; {'id': '22', 'type': 'dictionary', 'children': ['23', '26']}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'Name'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "'TrainingJobName'"}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'Value'"}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'StartTime'"}; {'id': '33', 'type': 'subscript', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_time_interval'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'start_time'"}; {'id': '38', 'type': 'pair', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'EndTime'"}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_time_interval'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'end_time'"}; {'id': '45', 'type': 'pair', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'Period'"}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_period'}; {'id': '50', 'type': 'pair', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'Statistics'"}; {'id': '52', 'type': 'list', 'children': ['53'], 'value': "['Average']"}; {'id': '53', 'type': 'string', 'children': [], 'value': "'Average'"}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'raw_cwm_data'}; {'id': '57', 'type': 'subscript', 'children': ['58', '67']}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_cloudwatch'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'get_metric_statistics'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'dictionary_splat', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'Datapoints'"}; {'id': '68', 'type': 'if_statement', 'children': ['69', '75']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '74'], 'value': '=='}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'raw_cwm_data'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '75', 'type': 'block', 'children': ['76', '85']}; {'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': 'logging'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'binary_operator', 'children': ['83', '84'], 'value': '%'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"Warning: No metrics called %s found"'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'metric_name'}; {'id': '85', 'type': 'return_statement', 'children': []}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'base_time'}; {'id': '89', 'type': 'subscript', 'children': ['90', '102']}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'raw_cwm_data'}; {'id': '94', 'type': 'keyword_argument', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '96', 'type': 'lambda', 'children': ['97', '99']}; {'id': '97', 'type': 'lambda_parameters', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'pt'}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'pt'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'Timestamp'"}; {'id': '102', 'type': 'string', 'children': [], 'value': "'Timestamp'"}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'all_xy'}; {'id': '106', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '107', 'type': 'for_statement', 'children': ['108', '109', '110']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'pt'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'raw_cwm_data'}; {'id': '110', 'type': 'block', 'children': ['111', '117', '130']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '114', 'type': 'subscript', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'pt'}; {'id': '116', 'type': 'string', 'children': [], 'value': "'Average'"}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '120', 'type': 'call', 'children': ['121', '129']}; {'id': '121', 'type': 'attribute', 'children': ['122', '128']}; {'id': '122', 'type': '()', 'children': ['123']}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '127'], 'value': '-'}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'pt'}; {'id': '126', 'type': 'string', 'children': [], 'value': "'Timestamp'"}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'base_time'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'total_seconds'}; {'id': '129', 'type': 'argument_list', 'children': []}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'all_xy'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'list', 'children': ['137', '138'], 'value': '[x, y]'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'all_xy'}; {'id': '142', 'type': 'call', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '144', 'type': 'argument_list', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'all_xy'}; {'id': '146', 'type': 'keyword_argument', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '148', 'type': 'lambda', 'children': ['149', '151']}; {'id': '149', 'type': 'lambda_parameters', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '151', 'type': 'subscript', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '153', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '154', 'type': 'for_statement', 'children': ['155', '158', '159']}; {'id': '155', 'type': 'pattern_list', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'elapsed_seconds'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'all_xy'}; {'id': '159', 'type': 'block', 'children': ['160']}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': '_add_single_metric'}; {'id': '165', 'type': 'argument_list', 'children': ['166', '167', '168']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'elapsed_seconds'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'metric_name'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'value'}
Fetch all the values of a named metric, and add them to _data
def token(self): if AUTH_TOKEN_HEADER in self.request.headers: return self.request.headers[AUTH_TOKEN_HEADER] else: return self.get_cookie(AUTH_COOKIE_NAME)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'token'}; {'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', '14', '23']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9'], 'value': 'in'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'AUTH_TOKEN_HEADER'}; {'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': 'request'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'subscript', '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': 'request'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'AUTH_TOKEN_HEADER'}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_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': 'get_cookie'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'AUTH_COOKIE_NAME'}
The token used for the request
def simplify_recursive(typ): if isinstance(typ, UnionType): return combine_types(typ.items) elif isinstance(typ, ClassType): simplified = ClassType(typ.name, [simplify_recursive(arg) for arg in typ.args]) args = simplified.args if (simplified.name == 'Dict' and len(args) == 2 and isinstance(args[0], ClassType) and args[0].name in ('str', 'Text') and isinstance(args[1], UnionType) and not is_optional(args[1])): return ClassType('Dict', [args[0], AnyType()]) return simplified elif isinstance(typ, TupleType): return TupleType([simplify_recursive(item) for item in typ.items]) return typ
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'simplify_recursive'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '5', 'type': 'block', 'children': ['6', '136']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '20', '115']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'UnionType'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'combine_types'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'elif_clause', 'children': ['21', '26']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ClassType'}; {'id': '26', 'type': 'block', 'children': ['27', '46', '52', '113']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'simplified'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ClassType'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '36', 'type': 'list_comprehension', 'children': ['37', '41']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'simplify_recursive'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'simplified'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '100']}; {'id': '53', 'type': '()', 'children': ['54']}; {'id': '54', 'type': 'boolean_operator', 'children': ['55', '93'], 'value': 'and'}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '86'], 'value': 'and'}; {'id': '56', 'type': 'boolean_operator', 'children': ['57', '77'], 'value': 'and'}; {'id': '57', 'type': 'boolean_operator', 'children': ['58', '70'], 'value': 'and'}; {'id': '58', 'type': 'boolean_operator', 'children': ['59', '64'], 'value': 'and'}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '63'], 'value': '=='}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'simplified'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'Dict'"}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '69'], 'value': '=='}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '76']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ClassType'}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '83'], 'value': 'in'}; {'id': '78', 'type': 'attribute', 'children': ['79', '82']}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '83', 'type': 'tuple', 'children': ['84', '85']}; {'id': '84', 'type': 'string', 'children': [], 'value': "'str'"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'Text'"}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '92']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'UnionType'}; {'id': '93', 'type': 'not_operator', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'is_optional'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'subscript', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '99', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'return_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'ClassType'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106']}; {'id': '105', 'type': 'string', 'children': [], 'value': "'Dict'"}; {'id': '106', 'type': 'list', 'children': ['107', '110'], 'value': '[args[0], AnyType()]'}; {'id': '107', 'type': 'subscript', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '109', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'AnyType'}; {'id': '112', 'type': 'argument_list', 'children': []}; {'id': '113', 'type': 'return_statement', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'simplified'}; {'id': '115', 'type': 'elif_clause', 'children': ['116', '121']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'TupleType'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'return_statement', 'children': ['123']}; {'id': '123', 'type': 'call', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'TupleType'}; {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'list_comprehension', 'children': ['127', '131']}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'simplify_recursive'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '131', 'type': 'for_in_clause', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '136', 'type': 'return_statement', 'children': ['137']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'typ'}
Simplify all components of a type.
def _remove_deprecated_options(self, old_version): old_defaults = self._load_old_defaults(old_version) for section in old_defaults.sections(): for option, _ in old_defaults.items(section, raw=self.raw): if self.get_default(section, option) is NoDefault: try: self.remove_option(section, option) if len(self.items(section, raw=self.raw)) == 0: self.remove_section(section) except cp.NoSectionError: self.remove_section(section)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_remove_deprecated_options'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'old_version'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'old_defaults'}; {'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': '_load_old_defaults'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'old_version'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '23']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'old_defaults'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sections'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'for_statement', 'children': ['25', '28', '39']}; {'id': '25', 'type': 'pattern_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'old_defaults'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'if_statement', 'children': ['41', '50']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '49'], 'value': 'is'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'get_default'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'NoDefault'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'try_statement', 'children': ['52', '86']}; {'id': '52', 'type': 'block', 'children': ['53', '61']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'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': 'remove_option'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '78']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '77'], 'value': '=='}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'remove_section'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '86', 'type': 'except_clause', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'cp'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'NoSectionError'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'remove_section'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'section'}
Remove options which are present in the .ini file but not in defaults
def _lab_to_rgb(labs): labs, n_dim = _check_color_dim(labs) y = (labs[:, 0] + 16.) / 116. x = (labs[:, 1] / 500.) + y z = y - (labs[:, 2] / 200.) xyz = np.concatenate(([x], [y], [z])) over = xyz > 0.2068966 xyz[over] = xyz[over] ** 3. xyz[~over] = (xyz[~over] - 0.13793103448275862) / 7.787 rgbs = np.dot(_xyz2rgb_norm, xyz).T over = rgbs > 0.0031308 rgbs[over] = 1.055 * (rgbs[over] ** (1. / 2.4)) - 0.055 rgbs[~over] *= 12.92 if n_dim == 4: rgbs = np.concatenate((rgbs, labs[:, 3]), axis=1) rgbs = np.clip(rgbs, 0., 1.) return rgbs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_lab_to_rgb'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'labs'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '28', '41', '54', '69', '75', '85', '100', '112', '118', '136', '143', '166', '177']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'labs'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'n_dim'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_check_color_dim'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'labs'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '27'], 'value': '/'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '26'], 'value': '+'}; {'id': '21', 'type': 'subscript', 'children': ['22', '23', '25']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'labs'}; {'id': '23', 'type': 'slice', 'children': ['24']}; {'id': '24', 'type': 'colon', 'children': []}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'float', 'children': [], 'value': '16.'}; {'id': '27', 'type': 'float', 'children': [], 'value': '116.'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '40'], 'value': '+'}; {'id': '32', 'type': '()', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '39'], 'value': '/'}; {'id': '34', 'type': 'subscript', 'children': ['35', '36', '38']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'labs'}; {'id': '36', 'type': 'slice', 'children': ['37']}; {'id': '37', 'type': 'colon', 'children': []}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'float', 'children': [], 'value': '500.'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '-'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '53'], 'value': '/'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50', '52']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'labs'}; {'id': '50', 'type': 'slice', 'children': ['51']}; {'id': '51', 'type': 'colon', 'children': []}; {'id': '52', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '53', 'type': 'float', 'children': [], 'value': '200.'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'concatenate'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'tuple', 'children': ['63', '65', '67']}; {'id': '63', 'type': 'list', 'children': ['64'], 'value': '[x]'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '65', 'type': 'list', 'children': ['66'], 'value': '[y]'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '67', 'type': 'list', 'children': ['68'], 'value': '[z]'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': '>'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '74', 'type': 'float', 'children': [], 'value': '0.2068966'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '80']}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '84'], 'value': '**'}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '84', 'type': 'float', 'children': [], 'value': '3.'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '91']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '89', 'type': 'unary_operator', 'children': ['90'], 'value': '~'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '99'], 'value': '/'}; {'id': '92', 'type': '()', 'children': ['93']}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '98'], 'value': '-'}; {'id': '94', 'type': 'subscript', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '96', 'type': 'unary_operator', 'children': ['97'], 'value': '~'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '98', 'type': 'float', 'children': [], 'value': '0.13793103448275862'}; {'id': '99', 'type': 'float', 'children': [], 'value': '7.787'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '103', 'type': 'attribute', 'children': ['104', '111']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'dot'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '_xyz2rgb_norm'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'xyz'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': '>'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '117', 'type': 'float', 'children': [], 'value': '0.0031308'}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'assignment', 'children': ['120', '123']}; {'id': '120', 'type': 'subscript', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '135'], 'value': '-'}; {'id': '124', 'type': 'binary_operator', 'children': ['125', '126'], 'value': '*'}; {'id': '125', 'type': 'float', 'children': [], 'value': '1.055'}; {'id': '126', 'type': '()', 'children': ['127']}; {'id': '127', 'type': 'binary_operator', 'children': ['128', '131'], 'value': '**'}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '131', 'type': '()', 'children': ['132']}; {'id': '132', 'type': 'binary_operator', 'children': ['133', '134'], 'value': '/'}; {'id': '133', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '134', 'type': 'float', 'children': [], 'value': '2.4'}; {'id': '135', 'type': 'float', 'children': [], 'value': '0.055'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'augmented_assignment', 'children': ['138', '142'], 'value': '*='}; {'id': '138', 'type': 'subscript', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '140', 'type': 'unary_operator', 'children': ['141'], 'value': '~'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'over'}; {'id': '142', 'type': 'float', 'children': [], 'value': '12.92'}; {'id': '143', 'type': 'if_statement', 'children': ['144', '147']}; {'id': '144', 'type': 'comparison_operator', 'children': ['145', '146'], 'value': '=='}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'n_dim'}; {'id': '146', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '147', 'type': 'block', 'children': ['148']}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'assignment', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'concatenate'}; {'id': '155', 'type': 'argument_list', 'children': ['156', '163']}; {'id': '156', 'type': 'tuple', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '158', 'type': 'subscript', 'children': ['159', '160', '162']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'labs'}; {'id': '160', 'type': 'slice', 'children': ['161']}; {'id': '161', 'type': 'colon', 'children': []}; {'id': '162', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '163', 'type': 'keyword_argument', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '165', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}; {'id': '167', 'type': 'assignment', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '169', 'type': 'call', 'children': ['170', '173']}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '173', 'type': 'argument_list', 'children': ['174', '175', '176']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'rgbs'}; {'id': '175', 'type': 'float', 'children': [], 'value': '0.'}; {'id': '176', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '177', 'type': 'return_statement', 'children': ['178']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'rgbs'}
Convert Nx3 or Nx4 lab to rgb
def __init_yaml(): global _yaml_initialized if not _yaml_initialized: _yaml_initialized = True yaml.add_constructor(u'tag:yaml.org,2002:Frame', _frame_constructor) yaml.add_constructor(u'tag:yaml.org,2002:Signal', _signal_constructor) yaml.add_representer(canmatrix.Frame, _frame_representer)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__init_yaml'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7']}; {'id': '5', 'type': 'global_statement', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': '_yaml_initialized'}; {'id': '7', 'type': 'if_statement', 'children': ['8', '10']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_yaml_initialized'}; {'id': '10', 'type': 'block', 'children': ['11', '15', '23', '31']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_yaml_initialized'}; {'id': '14', 'type': 'True', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'add_constructor'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "u'tag:yaml.org,2002:Frame'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_frame_constructor'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'add_constructor'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "u'tag:yaml.org,2002:Signal'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_signal_constructor'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'add_representer'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'canmatrix'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Frame'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_frame_representer'}
Lazy init yaml because canmatrix might not be fully loaded when loading this format.
def copy_from(self, other_state): for prop in self.properties().values(): setattr(self, prop.name, getattr(other_state, prop.name))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy_from'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'other_state'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '18']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'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': 'properties'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '27']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'other_state'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'name'}
Copy data from another shard state entity to self.
def _get_config(self, rel_path, view, api_version=1): self._require_min_api_version(api_version) params = view and dict(view=view) or None resp = self._get_resource_root().get(self._path() + '/' + rel_path, params=params) return json_to_config(resp, view == 'full')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rel_path'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'api_version'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '10', 'type': 'block', 'children': ['11', '18', '31', '55']}; {'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': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_require_min_api_version'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'api_version'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '21', 'type': 'boolean_operator', 'children': ['22', '30'], 'value': 'or'}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '24'], 'value': 'and'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '34', 'type': 'call', 'children': ['35', '42']}; {'id': '35', 'type': 'attribute', 'children': ['36', '41']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_get_resource_root'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '52']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '51'], 'value': '+'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '50'], 'value': '+'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_path'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'rel_path'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'json_to_config'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': '=='}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'full'"}
Retrieves an ApiConfig list from the given relative path.
def _convert_value(value): try: return restore(ast.literal_eval(value)) except (ValueError, SyntaxError): if SETTINGS.COMMAND_LINE.STRICT_PARSING: raise return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_value'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '18']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'restore'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'literal_eval'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '18', 'type': 'except_clause', 'children': ['19', '22']}; {'id': '19', 'type': 'tuple', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'SyntaxError'}; {'id': '22', 'type': 'block', 'children': ['23', '31']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'SETTINGS'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'COMMAND_LINE'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'STRICT_PARSING'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'raise_statement', 'children': []}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}
Parse string as python literal if possible and fallback to string.
def isRealmUser(self, realmname, username, environ): try: course = self.course_factory.get_course(realmname) ok = self.user_manager.has_admin_rights_on_course(course, username=username) return ok except: return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'isRealmUser'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'realmname'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'try_statement', 'children': ['10', '38']}; {'id': '10', 'type': 'block', 'children': ['11', '22', '36']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'course'}; {'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': 'course_factory'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get_course'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'realmname'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ok'}; {'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': 'user_manager'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'has_admin_rights_on_course'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'course'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ok'}; {'id': '38', 'type': 'except_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'False', 'children': []}
Returns True if this username is valid for the realm, False otherwise.
def gen_procfile(ctx, wsgi, dev): if wsgi is None: if os.path.exists("wsgi.py"): wsgi = "wsgi.py" elif os.path.exists("app.py"): wsgi = "app.py" else: wsgi = "app.py" ctx.invoke(gen_apppy) def write_procfile(filename, server_process, debug): processes = [server_process] + current_app.processes procfile = [] for name, cmd in procfile_processes(processes, debug).iteritems(): procfile.append("%s: %s" % (name, cmd)) with open(filename, "w") as f: f.write("\n".join(procfile)) write_procfile("Procfile", ("web", ["gunicorn", wsgi]), False) if dev: write_procfile("Procfile.dev", ("web", ["frasco", "serve"]), True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_procfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'wsgi'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dev'}; {'id': '7', 'type': 'block', 'children': ['8', '54', '123', '134']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'wsgi'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '22', '27', '41']}; {'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': 'os'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"wsgi.py"'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'wsgi'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"wsgi.py"'}; {'id': '27', 'type': 'elif_clause', 'children': ['28', '36']}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"app.py"'}; {'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': 'wsgi'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"app.py"'}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43', '47']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'wsgi'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"app.py"'}; {'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': 'ctx'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'invoke'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'gen_apppy'}; {'id': '54', 'type': 'function_definition', 'children': ['55', '56', '60']}; {'id': '55', 'type': 'function_name', 'children': [], 'value': 'write_procfile'}; {'id': '56', 'type': 'parameters', 'children': ['57', '58', '59']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'server_process'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '60', 'type': 'block', 'children': ['61', '70', '74', '99']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'processes'}; {'id': '64', 'type': 'binary_operator', 'children': ['65', '67'], 'value': '+'}; {'id': '65', 'type': 'list', 'children': ['66'], 'value': '[server_process]'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'server_process'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'processes'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'procfile'}; {'id': '73', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '74', 'type': 'for_statement', 'children': ['75', '78', '87']}; {'id': '75', 'type': 'pattern_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '78', 'type': 'call', 'children': ['79', '86']}; {'id': '79', 'type': 'attribute', 'children': ['80', '85']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'procfile_processes'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'processes'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '86', 'type': 'argument_list', 'children': []}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'procfile'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '96'], 'value': '%'}; {'id': '95', 'type': 'string', 'children': [], 'value': '"%s: %s"'}; {'id': '96', 'type': 'tuple', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '99', 'type': 'with_statement', 'children': ['100', '110']}; {'id': '100', 'type': 'with_clause', 'children': ['101']}; {'id': '101', 'type': 'with_item', 'children': ['102']}; {'id': '102', 'type': 'as_pattern', 'children': ['103', '108']}; {'id': '103', 'type': 'call', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '107', 'type': 'string', 'children': [], 'value': '"w"'}; {'id': '108', 'type': 'as_pattern_target', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '110', 'type': 'block', 'children': ['111']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'procfile'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'write_procfile'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128', '133']}; {'id': '127', 'type': 'string', 'children': [], 'value': '"Procfile"'}; {'id': '128', 'type': 'tuple', 'children': ['129', '130']}; {'id': '129', 'type': 'string', 'children': [], 'value': '"web"'}; {'id': '130', 'type': 'list', 'children': ['131', '132'], 'value': '["gunicorn", wsgi]'}; {'id': '131', 'type': 'string', 'children': [], 'value': '"gunicorn"'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'wsgi'}; {'id': '133', 'type': 'False', 'children': []}; {'id': '134', 'type': 'if_statement', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'dev'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'write_procfile'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142', '147']}; {'id': '141', 'type': 'string', 'children': [], 'value': '"Procfile.dev"'}; {'id': '142', 'type': 'tuple', 'children': ['143', '144']}; {'id': '143', 'type': 'string', 'children': [], 'value': '"web"'}; {'id': '144', 'type': 'list', 'children': ['145', '146'], 'value': '["frasco", "serve"]'}; {'id': '145', 'type': 'string', 'children': [], 'value': '"frasco"'}; {'id': '146', 'type': 'string', 'children': [], 'value': '"serve"'}; {'id': '147', 'type': 'True', 'children': []}
Generates Procfiles which can be used with honcho or foreman.
def indexables(self): if self._indexables is None: d = self.description self._indexables = [GenericIndexCol(name='index', axis=0)] for i, n in enumerate(d._v_names): dc = GenericDataIndexableCol( name=n, pos=i, values=[n], version=self.version) self._indexables.append(dc) return self._indexables
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'indexables'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '75']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'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': '_indexables'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '19', '34']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'description'}; {'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': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_indexables'}; {'id': '24', 'type': 'list', 'children': ['25'], 'value': "[GenericIndexCol(name='index', axis=0)]"}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'GenericIndexCol'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31']}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'index'"}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '34', 'type': 'for_statement', 'children': ['35', '38', '44']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_v_names'}; {'id': '44', 'type': 'block', 'children': ['45', '66']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dc'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'GenericDataIndexableCol'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '54', '57', '61']}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '59', 'type': 'list', 'children': ['60'], 'value': '[n]'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_indexables'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'dc'}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_indexables'}
create the indexables from the table description
def textbetween(variable, firstnum=None, secondnum=None, locationoftext='regular'): if locationoftext == 'regular': return variable[firstnum:secondnum] elif locationoftext == 'toend': return variable[firstnum:] elif locationoftext == 'tostart': return variable[:secondnum]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'textbetween'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'firstnum'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'secondnum'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'locationoftext'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'regular'"}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19', '27', '38']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '=='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'locationoftext'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'regular'"}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '23', 'type': 'slice', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'firstnum'}; {'id': '25', 'type': 'colon', 'children': []}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'secondnum'}; {'id': '27', 'type': 'elif_clause', 'children': ['28', '31']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': '=='}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'locationoftext'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'toend'"}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '35', 'type': 'slice', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'firstnum'}; {'id': '37', 'type': 'colon', 'children': []}; {'id': '38', 'type': 'elif_clause', 'children': ['39', '42']}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': '=='}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'locationoftext'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'tostart'"}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '46', 'type': 'slice', 'children': ['47', '48']}; {'id': '47', 'type': 'colon', 'children': []}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'secondnum'}
Get The Text Between Two Parts
def complex_out_dtype(self): if self.__complex_out_dtype is None: raise AttributeError( 'no complex variant of output dtype {} defined' ''.format(dtype_repr(self.scalar_out_dtype))) else: return self.__complex_out_dtype
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complex_out_dtype'}; {'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', '30']}; {'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': '__complex_out_dtype'}; {'id': '11', 'type': 'None', 'children': []}; {'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': 'AttributeError'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'concatenated_string', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'no complex variant of output dtype {} defined'"}; {'id': '21', 'type': 'string', 'children': [], 'value': "''"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dtype_repr'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'scalar_out_dtype'}; {'id': '30', 'type': 'else_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '__complex_out_dtype'}
The complex dtype corresponding to this space's `out_dtype`.
def date(ctx, year, month, day): return _date(conversions.to_integer(year, ctx), conversions.to_integer(month, ctx), conversions.to_integer(day, ctx))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'date'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_date'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '20', '27']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'conversions'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'to_integer'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'conversions'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'to_integer'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'conversions'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'to_integer'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ctx'}
Defines a date value
def npd_to_pmf(nodal_plane_dist, use_default=False): if isinstance(nodal_plane_dist, PMF): return nodal_plane_dist else: if use_default: return PMF([(1.0, NodalPlane(0.0, 90.0, 0.0))]) else: raise ValueError('Nodal Plane distribution not defined')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'npd_to_pmf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'nodal_plane_dist'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'use_default'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15', '18']}; {'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': 'nodal_plane_dist'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'PMF'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'nodal_plane_dist'}; {'id': '18', 'type': 'else_clause', 'children': ['19']}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '22', '36']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'use_default'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'PMF'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'list', 'children': ['28'], 'value': '[(1.0, NodalPlane(0.0, 90.0, 0.0))]'}; {'id': '28', 'type': 'tuple', 'children': ['29', '30']}; {'id': '29', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'NodalPlane'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '34', 'type': 'float', 'children': [], 'value': '90.0'}; {'id': '35', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'raise_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'Nodal Plane distribution not defined'"}
Returns the nodal plane distribution as an instance of the PMF class
def _from_dict(cls, _dict): args = {} if 'grammars' in _dict: args['grammars'] = [ Grammar._from_dict(x) for x in (_dict.get('grammars')) ] else: raise ValueError( 'Required property \'grammars\' not present in Grammars JSON') return cls(**args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15', '37']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'grammars'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'grammars'"}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Grammar'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_from_dict'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'for_in_clause', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '30', 'type': '()', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'grammars'"}; {'id': '37', 'type': 'else_clause', 'children': ['38']}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'raise_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'Required property \\'grammars\\' not present in Grammars JSON'"}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'dictionary_splat', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}
Initialize a Grammars object from a json dictionary.
def run(self): for msg in self.messages: col = getattr(msg, 'col', 0) yield msg.lineno, col, (msg.tpl % msg.message_args), msg.__class__
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'messages'}; {'id': '11', 'type': 'block', 'children': ['12', '21']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'col'"}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'yield', 'children': ['23']}; {'id': '23', 'type': 'expression_list', 'children': ['24', '27', '28', '36']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '28', 'type': '()', 'children': ['29']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '33'], 'value': '%'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tpl'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'message_args'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__class__'}
Yield the error messages.
def kdists(matrix, k=7, ix=None): ix = ix or kindex(matrix, k) return matrix[ix][np.newaxis].T
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'kdists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'matrix'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '22']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '17'], 'value': 'or'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'kindex'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'matrix'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '31']}; {'id': '24', 'type': 'subscript', 'children': ['25', '28']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'matrix'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'newaxis'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'T'}
Returns the k-th nearest distances, row-wise, as a column vector
def use_plenary_composition_view(self): self._object_views['composition'] = PLENARY for session in self._get_provider_sessions(): try: session.use_plenary_composition_view() except AttributeError: pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'use_plenary_composition_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '13']}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_object_views'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'composition'"}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'PLENARY'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_get_provider_sessions'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'try_statement', 'children': ['23', '30']}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'use_plenary_composition_view'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'except_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'pass_statement', 'children': []}
Pass through to provider CompositionLookupSession.use_plenary_composition_view
def _get_opts_seaborn(self, opts, style): if opts is None: if self.chart_opts is None: opts = {} else: opts = self.chart_opts if style is None: if self.chart_style is None: style = self.chart_style else: style = {} return opts, style
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_opts_seaborn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '7', 'type': 'block', 'children': ['8', '32', '56']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '19', '24']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '18'], 'value': 'is'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'chart_opts'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '23', 'type': 'dictionary', 'children': []}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'chart_opts'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'is'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '35', 'type': 'None', 'children': []}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '43', '50']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '42'], 'value': 'is'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'chart_style'}; {'id': '42', 'type': 'None', 'children': []}; {'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': 'style'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'chart_style'}; {'id': '50', 'type': 'else_clause', 'children': ['51']}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '55', 'type': 'dictionary', 'children': []}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'expression_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'style'}
Initialialize for chart rendering
def main(): actions = [] try: options, arguments = getopt.getopt(sys.argv[1:], 'cdh', [ 'convert', 'to-html', 'demo', 'help', ]) for option, value in options: if option in ('-c', '--convert', '--to-html'): actions.append(functools.partial(convert_command_output, *arguments)) arguments = [] elif option in ('-d', '--demo'): actions.append(demonstrate_colored_logging) elif option in ('-h', '--help'): usage(__doc__) return else: assert False, "Programming error: Unhandled option!" if not actions: usage(__doc__) return except Exception as e: warning("Error: %s", e) sys.exit(1) for function in actions: function()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '127']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '8', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '9', 'type': 'try_statement', 'children': ['10', '108']}; {'id': '10', 'type': 'block', 'children': ['11', '34', '98']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'getopt'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'getopt'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '28', '29']}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '25', 'type': 'slice', 'children': ['26', '27']}; {'id': '26', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '27', 'type': 'colon', 'children': []}; {'id': '28', 'type': 'string', 'children': [], 'value': "'cdh'"}; {'id': '29', 'type': 'list', 'children': ['30', '31', '32', '33'], 'value': "[\n 'convert', 'to-html', 'demo', 'help',\n ]"}; {'id': '30', 'type': 'string', 'children': [], 'value': "'convert'"}; {'id': '31', 'type': 'string', 'children': [], 'value': "'to-html'"}; {'id': '32', 'type': 'string', 'children': [], 'value': "'demo'"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'help'"}; {'id': '34', 'type': 'for_statement', 'children': ['35', '38', '39']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'if_statement', 'children': ['41', '47', '66', '80', '93']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': 'in'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '43', 'type': 'tuple', 'children': ['44', '45', '46']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'-c'"}; {'id': '45', 'type': 'string', 'children': [], 'value': "'--convert'"}; {'id': '46', 'type': 'string', 'children': [], 'value': "'--to-html'"}; {'id': '47', 'type': 'block', 'children': ['48', '62']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'functools'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'convert_command_output'}; {'id': '60', 'type': 'list_splat', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'arguments'}; {'id': '65', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '66', 'type': 'elif_clause', 'children': ['67', '72']}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': 'in'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '69', 'type': 'tuple', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'-d'"}; {'id': '71', 'type': 'string', 'children': [], 'value': "'--demo'"}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'demonstrate_colored_logging'}; {'id': '80', 'type': 'elif_clause', 'children': ['81', '86']}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '83'], 'value': 'in'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '83', 'type': 'tuple', 'children': ['84', '85']}; {'id': '84', 'type': 'string', 'children': [], 'value': "'-h'"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'--help'"}; {'id': '86', 'type': 'block', 'children': ['87', '92']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'usage'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '92', 'type': 'return_statement', 'children': []}; {'id': '93', 'type': 'else_clause', 'children': ['94']}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'assert_statement', 'children': ['96', '97']}; {'id': '96', 'type': 'False', 'children': []}; {'id': '97', 'type': 'string', 'children': [], 'value': '"Programming error: Unhandled option!"'}; {'id': '98', 'type': 'if_statement', 'children': ['99', '101']}; {'id': '99', 'type': 'not_operator', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '101', 'type': 'block', 'children': ['102', '107']}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'usage'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '107', 'type': 'return_statement', 'children': []}; {'id': '108', 'type': 'except_clause', 'children': ['109', '113']}; {'id': '109', 'type': 'as_pattern', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '111', 'type': 'as_pattern_target', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '113', 'type': 'block', 'children': ['114', '120']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '119']}; {'id': '118', 'type': 'string', 'children': [], 'value': '"Error: %s"'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'call', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '127', 'type': 'for_statement', 'children': ['128', '129', '130']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '130', 'type': 'block', 'children': ['131']}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '134', 'type': 'argument_list', 'children': []}
Command line interface for the ``coloredlogs`` program.
def page_prev(self): window_start = (self.parent.value('window_start') - self.parent.value('window_length')) if window_start < 0: return self.parent.overview.update_position(window_start)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'page_prev'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '27', '33']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'window_start'}; {'id': '9', 'type': '()', 'children': ['10']}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '19'], 'value': '-'}; {'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': 'parent'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'window_start'"}; {'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': 'parent'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'window_length'"}; {'id': '27', 'type': 'if_statement', 'children': ['28', '31']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': '<'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'window_start'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '42']}; {'id': '35', 'type': 'attribute', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'overview'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'update_position'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'window_start'}
Go to the previous page.
def close(self): for channel in self._listening_to: self.toredis.unsubscribe(channel) self.toredis.unsubscribe(self.group_pubsub)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_listening_to'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', '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': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'toredis'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'unsubscribe'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'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': 'toredis'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'unsubscribe'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'group_pubsub'}
Unsubscribe the group and all jobs being listened too
def stop(self): if self._thread is not None and self._thread.isAlive(): self._done.set()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop'}; {'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', '20']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '13'], 'value': 'and'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is not'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_thread'}; {'id': '12', 'type': 'None', 'children': []}; {'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': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_thread'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'isAlive'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'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': '_done'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '28', 'type': 'argument_list', 'children': []}
Stop the running task
def _setup_http_session(self): headers = {"Content-type": "application/json"} if (self._id_token): headers.update({"authorization": "Bearer {}".format( self._id_token)}) self._session.headers.update(headers) self._session.verify = False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setup_http_session'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '36', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '9', 'type': 'dictionary', 'children': ['10']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"Content-type"'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"application/json"'}; {'id': '13', 'type': 'if_statement', 'children': ['14', '18']}; {'id': '14', 'type': '()', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_id_token'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'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': 'headers'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'dictionary', 'children': ['26']}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"authorization"'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"Bearer {}"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_id_token'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '45']}; {'id': '38', 'type': 'attribute', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_session'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', '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': '_session'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'verify'}; {'id': '54', 'type': 'False', 'children': []}
Sets up the common HTTP session parameters used by requests.
def field_from_json(self, key_and_type, json_value): assert ':' in key_and_type key, type_code = key_and_type.split(':', 1) from_json = self.field_function(type_code, 'from_json') value = from_json(json_value) return key, value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'field_from_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key_and_type'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'json_value'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '24', '34', '41']}; {'id': '8', 'type': 'assert_statement', 'children': ['9']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'key_and_type'}; {'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': 'key'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'type_code'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key_and_type'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'from_json'}; {'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': 'field_function'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'type_code'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'from_json'"}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'from_json'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'json_value'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'expression_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'value'}
Convert a JSON-serializable representation back to a field.
def convert_table(app, docname, source): num_tables = 0 for i,j in enumerate(source): table = [] output = '' in_table = False for l in j.split('\n'): r = l.strip() if r.startswith('|'): table.append(r) in_table = True else: if in_table is True: converted = _convert_md_table_to_rst(table) if converted is '': print("Failed to convert the markdown table") print(table) else: num_tables += 1 output += converted in_table = False table = [] output += l + '\n' source[i] = output if num_tables > 0: print('Converted %d tables in %s' % (num_tables, docname))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'docname'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '128']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'num_tables'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'for_statement', 'children': ['13', '16', '20']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '20', 'type': 'block', 'children': ['21', '25', '29', '33', '122']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '28', 'type': 'string', 'children': [], 'value': "''"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'in_table'}; {'id': '32', 'type': 'False', 'children': []}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '41']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '41', 'type': 'block', 'children': ['42', '50']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'if_statement', 'children': ['51', '57', '69']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'|'"}; {'id': '57', 'type': 'block', 'children': ['58', '65']}; {'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': 'table'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'in_table'}; {'id': '68', 'type': 'True', 'children': []}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71', '116']}; {'id': '71', 'type': 'if_statement', 'children': ['72', '75']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': 'is'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'in_table'}; {'id': '74', 'type': 'True', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76', '83', '104', '108', '112']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'converted'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_convert_md_table_to_rst'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '83', 'type': 'if_statement', 'children': ['84', '87', '98']}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': 'is'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'converted'}; {'id': '86', 'type': 'string', 'children': [], 'value': "''"}; {'id': '87', 'type': 'block', 'children': ['88', '93']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'string', 'children': [], 'value': '"Failed to convert the markdown table"'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '98', 'type': 'else_clause', 'children': ['99']}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'augmented_assignment', 'children': ['102', '103'], 'value': '+='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'num_tables'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'augmented_assignment', 'children': ['106', '107'], 'value': '+='}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'converted'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'in_table'}; {'id': '111', 'type': 'False', 'children': []}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '115', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'augmented_assignment', 'children': ['118', '119'], 'value': '+='}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '121'], 'value': '+'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '121', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '127']}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '128', 'type': 'if_statement', 'children': ['129', '132']}; {'id': '129', 'type': 'comparison_operator', 'children': ['130', '131'], 'value': '>'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'num_tables'}; {'id': '131', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '132', 'type': 'block', 'children': ['133']}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'binary_operator', 'children': ['138', '139'], 'value': '%'}; {'id': '138', 'type': 'string', 'children': [], 'value': "'Converted %d tables in %s'"}; {'id': '139', 'type': 'tuple', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'num_tables'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'docname'}
Find tables in a markdown and then convert them into the rst format
def distance(a, b): R = 3963 lat1, lon1 = math.radians(a[0]), math.radians(a[1]) lat2, lon2 = math.radians(b[0]), math.radians(b[1]) return math.acos(math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(lon1 - lon2)) * R
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distance'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '33', '55']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '3963'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'lat1'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'lon1'}; {'id': '16', 'type': 'expression_list', 'children': ['17', '25']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'radians'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'radians'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'lat2'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'lon2'}; {'id': '38', 'type': 'expression_list', 'children': ['39', '47']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'radians'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'radians'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '98'], 'value': '*'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'acos'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '76'], 'value': '+'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '70'], 'value': '*'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'lat1'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'lat2'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '90'], 'value': '*'}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '84'], 'value': '*'}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'lat1'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'lat2'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '97'], 'value': '-'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'lon1'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'lon2'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'R'}
Calculates distance between two latitude-longitude coordinates.
def create_cookie(name, value, domain, httponly=None, **kwargs): if domain == 'localhost': domain = '' config = dict( name=name, value=value, version=0, port=None, domain=domain, path='/', secure=False, expires=None, discard=True, comment=None, comment_url=None, rfc2109=False, rest={'HttpOnly': httponly}, ) for key in kwargs: if key not in config: raise GrabMisuseError('Function `create_cookie` does not accept ' '`%s` argument' % key) config.update(**kwargs) config['rest']['HttpOnly'] = httponly config['port_specified'] = bool(config['port']) config['domain_specified'] = bool(config['domain']) config['domain_initial_dot'] = (config['domain'] or '').startswith('.') config['path_specified'] = bool(config['path']) return Cookie(**config)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_cookie'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'httponly'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'dictionary_splat_pattern', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '12', 'type': 'block', 'children': ['13', '22', '70', '88', '96', '104', '115', '126', '142', '153']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': '=='}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'localhost'"}; {'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': 'domain'}; {'id': '21', 'type': 'string', 'children': [], 'value': "''"}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31', '34', '37', '40', '43', '46', '49', '52', '55', '58', '61', '64']}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'secure'}; {'id': '48', 'type': 'False', 'children': []}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'expires'}; {'id': '51', 'type': 'None', 'children': []}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'discard'}; {'id': '54', 'type': 'True', 'children': []}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '57', 'type': 'None', 'children': []}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'comment_url'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'rfc2109'}; {'id': '63', 'type': 'False', 'children': []}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'rest'}; {'id': '66', 'type': 'dictionary', 'children': ['67']}; {'id': '67', 'type': 'pair', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': "'HttpOnly'"}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'httponly'}; {'id': '70', 'type': 'for_statement', 'children': ['71', '72', '73']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'if_statement', 'children': ['75', '78']}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '77'], 'value': 'not in'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'raise_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'GrabMisuseError'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '87'], 'value': '%'}; {'id': '84', 'type': 'concatenated_string', 'children': ['85', '86']}; {'id': '85', 'type': 'string', 'children': [], 'value': "'Function `create_cookie` does not accept '"}; {'id': '86', 'type': 'string', 'children': [], 'value': "'`%s` argument'"}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'dictionary_splat', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '103']}; {'id': '98', 'type': 'subscript', 'children': ['99', '102']}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'rest'"}; {'id': '102', 'type': 'string', 'children': [], 'value': "'HttpOnly'"}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'httponly'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '109']}; {'id': '106', 'type': 'subscript', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '108', 'type': 'string', 'children': [], 'value': "'port_specified'"}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'subscript', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'port'"}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '120']}; {'id': '117', 'type': 'subscript', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '119', 'type': 'string', 'children': [], 'value': "'domain_specified'"}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'subscript', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '125', 'type': 'string', 'children': [], 'value': "'domain'"}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '131']}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '130', 'type': 'string', 'children': [], 'value': "'domain_initial_dot'"}; {'id': '131', 'type': 'call', 'children': ['132', '140']}; {'id': '132', 'type': 'attribute', 'children': ['133', '139']}; {'id': '133', 'type': '()', 'children': ['134']}; {'id': '134', 'type': 'boolean_operator', 'children': ['135', '138'], 'value': 'or'}; {'id': '135', 'type': 'subscript', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '137', 'type': 'string', 'children': [], 'value': "'domain'"}; {'id': '138', 'type': 'string', 'children': [], 'value': "''"}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}; {'id': '143', 'type': 'assignment', 'children': ['144', '147']}; {'id': '144', 'type': 'subscript', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '146', 'type': 'string', 'children': [], 'value': "'path_specified'"}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'subscript', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '152', 'type': 'string', 'children': [], 'value': "'path'"}; {'id': '153', 'type': 'return_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'Cookie'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'dictionary_splat', 'children': ['158']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'config'}
Creates `cookielib.Cookie` instance
def must_contain(self, value, q, strict=False): if value is not None: if value.find(q) != -1: return self.shout('Value %r does not contain %r', strict, value, q)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'must_contain'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'strict'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '28']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is not'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '26']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '24'], 'value': '!='}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '24', 'type': 'unary_operator', 'children': ['25'], 'value': '-'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': []}; {'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': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'shout'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35', '36', '37']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'Value %r does not contain %r'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'strict'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'q'}
if value must contain q
def _raise_on_error(data: Union[str, dict]) -> None: if isinstance(data, str): raise_error(data) elif 'status' in data and data['status'] != 'success': raise_error(data['data']['message'])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_raise_on_error'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '9', 'type': 'type_parameter', 'children': ['10', '12']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23', '29']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'raise_error'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '29', 'type': 'elif_clause', 'children': ['30', '39']}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '34'], 'value': 'and'}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': 'in'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '38'], 'value': '!='}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '38', 'type': 'string', 'children': [], 'value': "'success'"}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'raise_error'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '48', 'type': 'string', 'children': [], 'value': "'message'"}
Raise the appropriate exception on error.
def d(msg, *args, **kwargs): return logging.log(DEBUG, msg, *args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'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': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '18', '20']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'DEBUG'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '18', 'type': 'list_splat', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'dictionary_splat', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
log a message at debug level;
def _serialize(self, include_run_logs=False, strict_json=False): result = {'command': self.command, 'name': self.name, 'started_at': self.started_at, 'completed_at': self.completed_at, 'success': self.successful, 'soft_timeout': self.soft_timeout, 'hard_timeout': self.hard_timeout, 'hostname': self.hostname} if include_run_logs: last_run = self.backend.get_latest_run_log(self.parent_job.job_id, self.name) if last_run: run_log = last_run.get('tasks', {}).get(self.name, {}) if run_log: result['run_log'] = run_log if strict_json: result = json.loads(json.dumps(result, cls=StrictJSONEncoder)) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_serialize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'include_run_logs'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'strict_json'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '56', '107', '127']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '15', 'type': 'dictionary', 'children': ['16', '21', '26', '31', '36', '41', '46', '51']}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'command'"}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'started_at'"}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'started_at'}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'completed_at'"}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'completed_at'}; {'id': '36', 'type': 'pair', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'success'"}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'successful'}; {'id': '41', 'type': 'pair', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'soft_timeout'"}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'soft_timeout'}; {'id': '46', 'type': 'pair', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'hard_timeout'"}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'hard_timeout'}; {'id': '51', 'type': 'pair', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'hostname'"}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'hostname'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'include_run_logs'}; {'id': '58', 'type': 'block', 'children': ['59', '77']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'last_run'}; {'id': '62', 'type': 'call', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'get_latest_run_log'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'parent_job'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'job_id'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '77', 'type': 'if_statement', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'last_run'}; {'id': '79', 'type': 'block', 'children': ['80', '98']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'run_log'}; {'id': '83', 'type': 'call', 'children': ['84', '93']}; {'id': '84', 'type': 'attribute', 'children': ['85', '92']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'last_run'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': "'tasks'"}; {'id': '91', 'type': 'dictionary', 'children': []}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '97', 'type': 'dictionary', 'children': []}; {'id': '98', 'type': 'if_statement', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'run_log'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '106']}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '105', 'type': 'string', 'children': [], 'value': "'run_log'"}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'run_log'}; {'id': '107', 'type': 'if_statement', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'strict_json'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '124', 'type': 'keyword_argument', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'StrictJSONEncoder'}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'result'}
Serialize a representation of this Task to a Python dict.
def _build_graph(self): if not self.colors: self.palette = self.env.get_template('palette.js') self.template_vars.update({'palette': self.palette.render()}) self.colors = {x['name']: 'palette.color()' for x in self.json_data} template_vars = [] for index, dataset in enumerate(self.json_data): group = 'datagroup' + str(index) template_vars.append({'name': str(dataset['name']), 'color': self.colors[dataset['name']], 'data': 'json[{0}].data'.format(index)}) variables = {'dataset': template_vars, 'width': self.width, 'height': self.height, 'render': self.renderer, 'chart_id': self.chart_id} if not self.y_zero: variables.update({'min': "min: 'auto',"}) graph = self.env.get_template('graph.js') self.template_vars.update({'graph': graph.render(variables)})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_graph'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '59', '63', '115', '142', '158', '169']}; {'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': 'colors'}; {'id': '11', 'type': 'block', 'children': ['12', '25', '43']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'palette'}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'get_template'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'palette.js'"}; {'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': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'template_vars'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'dictionary', 'children': ['34']}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'palette'"}; {'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': 'palette'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'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': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '48', 'type': 'dictionary_comprehension', 'children': ['49', '54']}; {'id': '49', 'type': 'pair', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '53', 'type': 'string', 'children': [], 'value': "'palette.color()'"}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'json_data'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'template_vars'}; {'id': '62', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '63', 'type': 'for_statement', 'children': ['64', '67', '73']}; {'id': '64', 'type': 'pattern_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'json_data'}; {'id': '73', 'type': 'block', 'children': ['74', '83']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '79'], 'value': '+'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'datagroup'"}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'index'}; {'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': 'template_vars'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'dictionary', 'children': ['90', '98', '107']}; {'id': '90', 'type': 'pair', 'children': ['91', '92']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '97', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '98', 'type': 'pair', 'children': ['99', '100']}; {'id': '99', 'type': 'string', 'children': [], 'value': "'color'"}; {'id': '100', 'type': 'subscript', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '104', 'type': 'subscript', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '106', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '107', 'type': 'pair', 'children': ['108', '109']}; {'id': '108', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'string', 'children': [], 'value': "'json[{0}].data'"}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '118', 'type': 'dictionary', 'children': ['119', '122', '127', '132', '137']}; {'id': '119', 'type': 'pair', 'children': ['120', '121']}; {'id': '120', 'type': 'string', 'children': [], 'value': "'dataset'"}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'template_vars'}; {'id': '122', 'type': 'pair', 'children': ['123', '124']}; {'id': '123', 'type': 'string', 'children': [], 'value': "'width'"}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '127', 'type': 'pair', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': "'height'"}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '132', 'type': 'pair', 'children': ['133', '134']}; {'id': '133', 'type': 'string', 'children': [], 'value': "'render'"}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'renderer'}; {'id': '137', 'type': 'pair', 'children': ['138', '139']}; {'id': '138', 'type': 'string', 'children': [], 'value': "'chart_id'"}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'chart_id'}; {'id': '142', 'type': 'if_statement', 'children': ['143', '147']}; {'id': '143', 'type': 'not_operator', 'children': ['144']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'y_zero'}; {'id': '147', 'type': 'block', 'children': ['148']}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'dictionary', 'children': ['155']}; {'id': '155', 'type': 'pair', 'children': ['156', '157']}; {'id': '156', 'type': 'string', 'children': [], 'value': "'min'"}; {'id': '157', 'type': 'string', 'children': [], 'value': '"min: \'auto\',"'}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}; {'id': '159', 'type': 'assignment', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '161', 'type': 'call', 'children': ['162', '167']}; {'id': '162', 'type': 'attribute', 'children': ['163', '166']}; {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'get_template'}; {'id': '167', 'type': 'argument_list', 'children': ['168']}; {'id': '168', 'type': 'string', 'children': [], 'value': "'graph.js'"}; {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '176']}; {'id': '171', 'type': 'attribute', 'children': ['172', '175']}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'template_vars'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '176', 'type': 'argument_list', 'children': ['177']}; {'id': '177', 'type': 'dictionary', 'children': ['178']}; {'id': '178', 'type': 'pair', 'children': ['179', '180']}; {'id': '179', 'type': 'string', 'children': [], 'value': "'graph'"}; {'id': '180', 'type': 'call', 'children': ['181', '184']}; {'id': '181', 'type': 'attribute', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '184', 'type': 'argument_list', 'children': ['185']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'variables'}
Build Rickshaw graph syntax with all data
def exclude(self, d, item): try: md = d.__metadata__ pmd = getattr(md, '__print__', None) if pmd is None: return False excludes = getattr(pmd, 'excludes', []) return ( item[0] in excludes ) except: pass return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exclude'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '7', 'type': 'block', 'children': ['8', '51']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '48']}; {'id': '9', 'type': 'block', 'children': ['10', '16', '25', '32', '41']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'md'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '__metadata__'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pmd'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'md'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'__print__'"}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pmd'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'False', 'children': []}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'excludes'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'pmd'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'excludes'"}; {'id': '40', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': 'in'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'excludes'}; {'id': '48', 'type': 'except_clause', 'children': ['49']}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'pass_statement', 'children': []}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'False', 'children': []}
check metadata for excluded items
def munge_source(v): lines = v.split('\n') if not lines: return tuple(), '' firstline = lines[0].lstrip() while firstline == '' or firstline[0] == '@': del lines[0] firstline = lines[0].lstrip() if not lines: return tuple(), '' params = tuple( parm.strip() for parm in sig_ex.match(lines[0]).group(1).split(',') ) del lines[0] if not lines: return params, '' if lines and lines[-1].strip() == 'pass': del lines[-1] return params, dedent('\n'.join(lines))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'munge_source'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '25', '35', '60', '70', '101', '105', '113', '132']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '15', 'type': 'if_statement', 'children': ['16', '18']}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'expression_list', 'children': ['21', '24']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'string', 'children': [], 'value': "''"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'firstline'}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'lstrip'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'while_statement', 'children': ['36', '45']}; {'id': '36', 'type': 'boolean_operator', 'children': ['37', '40'], 'value': 'or'}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '=='}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'firstline'}; {'id': '39', 'type': 'string', 'children': [], 'value': "''"}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '44'], 'value': '=='}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'firstline'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'@'"}; {'id': '45', 'type': 'block', 'children': ['46', '50']}; {'id': '46', 'type': 'delete_statement', 'children': ['47']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'firstline'}; {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'lstrip'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'if_statement', 'children': ['61', '63']}; {'id': '61', 'type': 'not_operator', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'expression_list', 'children': ['66', '69']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'string', 'children': [], 'value': "''"}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '75', 'type': 'generator_expression', 'children': ['76', '81']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'parm'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'id': '81', 'type': 'for_in_clause', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'parm'}; {'id': '83', 'type': 'call', 'children': ['84', '99']}; {'id': '84', 'type': 'attribute', 'children': ['85', '98']}; {'id': '85', 'type': 'call', 'children': ['86', '96']}; {'id': '86', 'type': 'attribute', 'children': ['87', '95']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'sig_ex'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'string', 'children': [], 'value': "','"}; {'id': '101', 'type': 'delete_statement', 'children': ['102']}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '104', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '108']}; {'id': '106', 'type': 'not_operator', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '108', 'type': 'block', 'children': ['109']}; {'id': '109', 'type': 'return_statement', 'children': ['110']}; {'id': '110', 'type': 'expression_list', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '112', 'type': 'string', 'children': [], 'value': "''"}; {'id': '113', 'type': 'if_statement', 'children': ['114', '126']}; {'id': '114', 'type': 'boolean_operator', 'children': ['115', '116'], 'value': 'and'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '116', 'type': 'comparison_operator', 'children': ['117', '125'], 'value': '=='}; {'id': '117', 'type': 'call', 'children': ['118', '124']}; {'id': '118', 'type': 'attribute', 'children': ['119', '123']}; {'id': '119', 'type': 'subscript', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '121', 'type': 'unary_operator', 'children': ['122'], 'value': '-'}; {'id': '122', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '124', 'type': 'argument_list', 'children': []}; {'id': '125', 'type': 'string', 'children': [], 'value': "'pass'"}; {'id': '126', 'type': 'block', 'children': ['127']}; {'id': '127', 'type': 'delete_statement', 'children': ['128']}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '130', 'type': 'unary_operator', 'children': ['131'], 'value': '-'}; {'id': '131', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '132', 'type': 'return_statement', 'children': ['133']}; {'id': '133', 'type': 'expression_list', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'dedent'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'lines'}
Take Python source code, return a pair of its parameters and the rest of it dedented
def rm(venv_name): inenv = InenvManager() venv = inenv.get_venv(venv_name) click.confirm("Delete dir {}".format(venv.path)) shutil.rmtree(venv.path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rm'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'venv_name'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '21', '35']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'inenv'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'InenvManager'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'venv'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'inenv'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_venv'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'venv_name'}; {'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': 'click'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'confirm'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': '"Delete dir {}"'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'venv'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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': 'shutil'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'rmtree'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'venv'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'path'}
Removes the venv by name
def bool_str(string): if string not in BOOL_STRS: raise ValueError('Invalid boolean string: "{}"'.format(string)) return True if string == 'true' else False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bool_str'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9'], 'value': 'not in'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'BOOL_STRS'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'raise_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '\'Invalid boolean string: "{}"\''}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'conditional_expression', 'children': ['23', '24', '27'], 'value': 'if'}; {'id': '23', 'type': 'True', 'children': []}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': '=='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'true'"}; {'id': '27', 'type': 'False', 'children': []}
Returns a boolean from a string imput of 'true' or 'false
def describe(self): description = { 'description': self._description, 'type': self.name, } description.update(self.extra_params) return description
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'describe'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '29']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '15']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'description'"}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_description'}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'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': 'description'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'update'}; {'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': 'extra_params'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'description'}
Provide a dictionary with information describing itself.
def initialize(self): if self._pooler is None: params = { "inputWidth": self.inputWidth, "lateralInputWidths": [self.cellCount] * self.numOtherCorticalColumns, "cellCount": self.cellCount, "sdrSize": self.sdrSize, "onlineLearning": self.onlineLearning, "maxSdrSize": self.maxSdrSize, "minSdrSize": self.minSdrSize, "synPermProximalInc": self.synPermProximalInc, "synPermProximalDec": self.synPermProximalDec, "initialProximalPermanence": self.initialProximalPermanence, "minThresholdProximal": self.minThresholdProximal, "sampleSizeProximal": self.sampleSizeProximal, "connectedPermanenceProximal": self.connectedPermanenceProximal, "predictedInhibitionThreshold": self.predictedInhibitionThreshold, "synPermDistalInc": self.synPermDistalInc, "synPermDistalDec": self.synPermDistalDec, "initialDistalPermanence": self.initialDistalPermanence, "activationThresholdDistal": self.activationThresholdDistal, "sampleSizeDistal": self.sampleSizeDistal, "connectedPermanenceDistal": self.connectedPermanenceDistal, "inertiaFactor": self.inertiaFactor, "seed": self.seed, } self._pooler = ColumnPooler(**params)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initialize'}; {'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']}; {'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': '_pooler'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '132']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '16', 'type': 'dictionary', 'children': ['17', '22', '32', '37', '42', '47', '52', '57', '62', '67', '72', '77', '82', '87', '92', '97', '102', '107', '112', '117', '122', '127']}; {'id': '17', 'type': 'pair', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"inputWidth"'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'inputWidth'}; {'id': '22', 'type': 'pair', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"lateralInputWidths"'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '29'], 'value': '*'}; {'id': '25', 'type': 'list', 'children': ['26'], 'value': '[self.cellCount]'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cellCount'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'numOtherCorticalColumns'}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"cellCount"'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cellCount'}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"sdrSize"'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'sdrSize'}; {'id': '42', 'type': 'pair', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"onlineLearning"'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'onlineLearning'}; {'id': '47', 'type': 'pair', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"maxSdrSize"'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'maxSdrSize'}; {'id': '52', 'type': 'pair', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"minSdrSize"'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'minSdrSize'}; {'id': '57', 'type': 'pair', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': '"synPermProximalInc"'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'synPermProximalInc'}; {'id': '62', 'type': 'pair', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': '"synPermProximalDec"'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'synPermProximalDec'}; {'id': '67', 'type': 'pair', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': '"initialProximalPermanence"'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'initialProximalPermanence'}; {'id': '72', 'type': 'pair', 'children': ['73', '74']}; {'id': '73', 'type': 'string', 'children': [], 'value': '"minThresholdProximal"'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'minThresholdProximal'}; {'id': '77', 'type': 'pair', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': '"sampleSizeProximal"'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'sampleSizeProximal'}; {'id': '82', 'type': 'pair', 'children': ['83', '84']}; {'id': '83', 'type': 'string', 'children': [], 'value': '"connectedPermanenceProximal"'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'connectedPermanenceProximal'}; {'id': '87', 'type': 'pair', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': '"predictedInhibitionThreshold"'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'predictedInhibitionThreshold'}; {'id': '92', 'type': 'pair', 'children': ['93', '94']}; {'id': '93', 'type': 'string', 'children': [], 'value': '"synPermDistalInc"'}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'synPermDistalInc'}; {'id': '97', 'type': 'pair', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': '"synPermDistalDec"'}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'synPermDistalDec'}; {'id': '102', 'type': 'pair', 'children': ['103', '104']}; {'id': '103', 'type': 'string', 'children': [], 'value': '"initialDistalPermanence"'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'initialDistalPermanence'}; {'id': '107', 'type': 'pair', 'children': ['108', '109']}; {'id': '108', 'type': 'string', 'children': [], 'value': '"activationThresholdDistal"'}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'activationThresholdDistal'}; {'id': '112', 'type': 'pair', 'children': ['113', '114']}; {'id': '113', 'type': 'string', 'children': [], 'value': '"sampleSizeDistal"'}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'sampleSizeDistal'}; {'id': '117', 'type': 'pair', 'children': ['118', '119']}; {'id': '118', 'type': 'string', 'children': [], 'value': '"connectedPermanenceDistal"'}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'connectedPermanenceDistal'}; {'id': '122', 'type': 'pair', 'children': ['123', '124']}; {'id': '123', 'type': 'string', 'children': [], 'value': '"inertiaFactor"'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'inertiaFactor'}; {'id': '127', 'type': 'pair', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': '"seed"'}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': '_pooler'}; {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'ColumnPooler'}; {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'dictionary_splat', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'params'}
Initialize the internal objects.
def read_ncstream_err(fobj): err = read_proto_object(fobj, stream.Error) raise RuntimeError(err.message)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_ncstream_err'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fobj'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'read_proto_object'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'fobj'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Error'}; {'id': '16', 'type': 'raise_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'message'}
Handle reading an NcStream error from a file-like object and raise as error.
def makeref2namesdct(name2refdct): ref2namesdct = {} for key, values in name2refdct.items(): for value in values: ref2namesdct.setdefault(value, set()).add(key) return ref2namesdct
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'makeref2namesdct'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name2refdct'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '39']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ref2namesdct'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '14', '19']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'name2refdct'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '37']}; {'id': '26', 'type': 'attribute', 'children': ['27', '36']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ref2namesdct'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ref2namesdct'}
make the ref2namesdct in the idd_index
def _rank_qr(self, choices): from bernard.platforms.facebook import layers as fbl try: qr = self.request.get_layer(fbl.QuickReply) self.chosen = choices[qr.slug] self.slug = qr.slug if self.when is None or self.when == qr.slug: return 1.0 except KeyError: pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_rank_qr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'choices'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'import_from_statement', 'children': ['8', '12']}; {'id': '8', 'type': 'dotted_name', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'bernard'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'platforms'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'facebook'}; {'id': '12', 'type': 'aliased_import', 'children': ['13', '15']}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'layers'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'fbl'}; {'id': '16', 'type': 'try_statement', 'children': ['17', '66']}; {'id': '17', 'type': 'block', 'children': ['18', '31', '41', '49']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'qr'}; {'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': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get_layer'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'fbl'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'QuickReply'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'chosen'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'choices'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'qr'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'slug'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'slug'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'qr'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'slug'}; {'id': '49', 'type': 'if_statement', 'children': ['50', '63']}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '56'], 'value': 'or'}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': 'is'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'when'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '60'], 'value': '=='}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'when'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'qr'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'slug'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '66', 'type': 'except_clause', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'pass_statement', 'children': []}
Look for the QuickReply layer's slug into available choices.
def sortable_title(instance): title = plone_sortable_title(instance) if safe_callable(title): title = title() return title.lower()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sortable_title'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'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': 'title'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'plone_sortable_title'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '13', 'type': 'if_statement', 'children': ['14', '18']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'safe_callable'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '30', 'type': 'argument_list', 'children': []}
Uses the default Plone sortable_text index lower-case
def dnd_endSnooze(self, **kwargs) -> SlackResponse: self._validate_xoxp_token() return self.api_call("dnd.endSnooze", json=kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dnd_endSnooze'}; {'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': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'SlackResponse'}; {'id': '9', 'type': 'block', 'children': ['10', '16']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'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': '_validate_xoxp_token'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'api_call'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"dnd.endSnooze"'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Ends the current user's snooze mode immediately.
def data_filler_customer(self, number_of_rows, pipe): try: for i in range(number_of_rows): pipe.hmset('customer:%s' % i, { 'id': rnd_id_generator(self), 'name': self.faker.first_name(), 'lastname': self.faker.last_name(), 'address': self.faker.address(), 'country': self.faker.country(), 'city': self.faker.city(), 'registry_date': self.faker.date(pattern="%d-%m-%Y"), 'birthdate': self.faker.date(pattern="%d-%m-%Y"), 'email': self.faker.safe_email(), 'phone_number': self.faker.phone_number(), 'locale': self.faker.locale() }) pipe.execute() logger.warning('customer Commits are successful after write job!', extra=d) except Exception as e: logger.error(e, extra=d)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_filler_customer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'number_of_rows'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'pipe'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '145']}; {'id': '9', 'type': 'block', 'children': ['10', '129', '135']}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '16']}; {'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': 'identifier', 'children': [], 'value': 'number_of_rows'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'pipe'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'hmset'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '%'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'customer:%s'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '26', 'type': 'dictionary', 'children': ['27', '33', '42', '51', '60', '69', '78', '90', '102', '111', '120']}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'rnd_id_generator'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'first_name'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'pair', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'lastname'"}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'last_name'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'pair', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'address'"}; {'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': 'faker'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'country'"}; {'id': '62', 'type': 'call', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'country'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'pair', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'city'"}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'city'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'pair', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "'registry_date'"}; {'id': '80', 'type': 'call', 'children': ['81', '86']}; {'id': '81', 'type': 'attribute', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '89', 'type': 'string', 'children': [], 'value': '"%d-%m-%Y"'}; {'id': '90', 'type': 'pair', 'children': ['91', '92']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'birthdate'"}; {'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': 'faker'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"%d-%m-%Y"'}; {'id': '102', 'type': 'pair', 'children': ['103', '104']}; {'id': '103', 'type': 'string', 'children': [], 'value': "'email'"}; {'id': '104', 'type': 'call', 'children': ['105', '110']}; {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'safe_email'}; {'id': '110', 'type': 'argument_list', 'children': []}; {'id': '111', 'type': 'pair', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'phone_number'"}; {'id': '113', 'type': 'call', 'children': ['114', '119']}; {'id': '114', 'type': 'attribute', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'phone_number'}; {'id': '119', 'type': 'argument_list', 'children': []}; {'id': '120', 'type': 'pair', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': "'locale'"}; {'id': '122', 'type': 'call', 'children': ['123', '128']}; {'id': '123', 'type': 'attribute', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'faker'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '128', 'type': 'argument_list', 'children': []}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'pipe'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '134', 'type': 'argument_list', 'children': []}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'call', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142']}; {'id': '141', 'type': 'string', 'children': [], 'value': "'customer Commits are successful after write job!'"}; {'id': '142', 'type': 'keyword_argument', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '145', 'type': 'except_clause', 'children': ['146', '150']}; {'id': '146', 'type': 'as_pattern', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '148', 'type': 'as_pattern_target', 'children': ['149']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '150', 'type': 'block', 'children': ['151']}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '156', 'type': 'argument_list', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '158', 'type': 'keyword_argument', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'd'}
creates keys with customer data
def _split_str(s, n): length = len(s) return [s[i:i + n] for i in range(0, length, n)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_split_str'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '6', 'type': 'block', 'children': ['7', '14']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'length'}; {'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': 's'}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'list_comprehension', 'children': ['16', '24']}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '18', 'type': 'slice', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '20', 'type': 'colon', 'children': []}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '+'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '24', 'type': 'for_in_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '31']}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'n'}
split string into list of strings by specified number.
def refresh_all_state_machines(self): self.refresh_state_machines(list(self.model.state_machine_manager.state_machines.keys()))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refresh_all_state_machines'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'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': 'refresh_state_machines'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '25']}; {'id': '16', 'type': 'attribute', 'children': ['17', '24']}; {'id': '17', 'type': 'attribute', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'state_machine_manager'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'state_machines'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '25', 'type': 'argument_list', 'children': []}
Refreshes all state machine tabs
def _update_staticmethod(self, oldsm, newsm): self._update(None, None, oldsm.__get__(0), newsm.__get__(0))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_staticmethod'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'oldsm'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'newsm'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_update'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '16', '22']}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'oldsm'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '__get__'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'newsm'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '__get__'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}
Update a staticmethod update.
def remove(self): self._multivol.deallocate(self.id) ARRAY_CACHE.pop(self.id, None) PIXEL_CACHE.pop(self.id, None)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '27']}; {'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': '_multivol'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'deallocate'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ARRAY_CACHE'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'PIXEL_CACHE'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '36', 'type': 'None', 'children': []}
Remove the layer artist for good
def pick_summary_data(key, summary_df, selected_summaries): selected_summaries_dict = create_selected_summaries_dict(selected_summaries) value = selected_summaries_dict[key] return summary_df.iloc[:, summary_df.columns.get_level_values(1) == value]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pick_summary_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'summary_df'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'selected_summaries'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '21']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'selected_summaries_dict'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'create_selected_summaries_dict'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'selected_summaries'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'selected_summaries_dict'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'subscript', 'children': ['23', '26', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'summary_df'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'iloc'}; {'id': '26', 'type': 'slice', 'children': ['27']}; {'id': '27', 'type': 'colon', 'children': []}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '37'], 'value': '=='}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'summary_df'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get_level_values'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}
picks the selected pandas.DataFrame
def wandb_pty(resize=True): master_fd, slave_fd = pty.openpty() try: tty.setraw(master_fd) except termios.error: pass if resize: if SIGWINCH_HANDLER is not None: SIGWINCH_HANDLER.add_fd(master_fd) return master_fd, slave_fd
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wandb_pty'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'resize'}; {'id': '6', 'type': 'True', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '18', '33', '48']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'master_fd'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'slave_fd'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pty'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'openpty'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'try_statement', 'children': ['19', '27']}; {'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': 'tty'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'setraw'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'master_fd'}; {'id': '27', 'type': 'except_clause', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'termios'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'pass_statement', 'children': []}; {'id': '33', 'type': 'if_statement', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'resize'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'is not'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'SIGWINCH_HANDLER'}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}; {'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': 'SIGWINCH_HANDLER'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'add_fd'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'master_fd'}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'expression_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'master_fd'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'slave_fd'}
Get a PTY set to raw mode and registered to hear about window size changes.
def _sign(self,params): for k, v in params.iteritems(): if type(v) == int: v = str(v) elif type(v) == float: v = '%.2f'%v elif type(v) in (list, set): v = ','.join([str(i) for i in v]) elif type(v) == bool: v = 'true' if v else 'false' elif type(v) == datetime.datetime: v = v.strftime('%Y-%m-%d %X') if type(v) == unicode: params[k] = v.encode('utf-8') else: params[k] = v src = self.APP_SECRET + ''.join(["%s%s" % (k, v) for k, v in sorted(params.iteritems())]) return md5(src).hexdigest().upper()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sign'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '6', 'type': 'block', 'children': ['7', '133', '163']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '11', '16']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '106']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '24', '32', '46', '72', '87']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '23'], 'value': '=='}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '32', 'type': 'elif_clause', 'children': ['33', '39']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '38'], 'value': '=='}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'float'}; {'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': 'v'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '%'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'%.2f'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '46', 'type': 'elif_clause', 'children': ['47', '55']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '52'], 'value': 'in'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '52', 'type': 'tuple', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "','"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'list_comprehension', 'children': ['65', '69']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '69', 'type': 'for_in_clause', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '72', 'type': 'elif_clause', 'children': ['73', '79']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '78'], 'value': '=='}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '83', 'type': 'conditional_expression', 'children': ['84', '85', '86'], 'value': 'if'}; {'id': '84', 'type': 'string', 'children': [], 'value': "'true'"}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '86', 'type': 'string', 'children': [], 'value': "'false'"}; {'id': '87', 'type': 'elif_clause', 'children': ['88', '96']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '93'], 'value': '=='}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'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': 'v'}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'string', 'children': [], 'value': "'%Y-%m-%d %X'"}; {'id': '106', 'type': 'if_statement', 'children': ['107', '113', '125']}; {'id': '107', 'type': 'comparison_operator', 'children': ['108', '112'], 'value': '=='}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'assignment', 'children': ['116', '119']}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '125', 'type': 'else_clause', 'children': ['126']}; {'id': '126', 'type': 'block', 'children': ['127']}; {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '132']}; {'id': '129', 'type': 'subscript', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '136', 'type': 'binary_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': 'APP_SECRET'}; {'id': '140', 'type': 'call', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'string', 'children': [], 'value': "''"}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'list_comprehension', 'children': ['146', '151']}; {'id': '146', 'type': 'binary_operator', 'children': ['147', '148'], 'value': '%'}; {'id': '147', 'type': 'string', 'children': [], 'value': '"%s%s"'}; {'id': '148', 'type': 'tuple', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '151', 'type': 'for_in_clause', 'children': ['152', '155']}; {'id': '152', 'type': 'pattern_list', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '155', 'type': 'call', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'call', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '162', 'type': 'argument_list', 'children': []}; {'id': '163', 'type': 'return_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '175']}; {'id': '165', 'type': 'attribute', 'children': ['166', '174']}; {'id': '166', 'type': 'call', 'children': ['167', '173']}; {'id': '167', 'type': 'attribute', 'children': ['168', '172']}; {'id': '168', 'type': 'call', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'hexdigest'}; {'id': '173', 'type': 'argument_list', 'children': []}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '175', 'type': 'argument_list', 'children': []}
Generate API sign code
def _save_to(self, im, path, format=None): format = format or im.format if not format: _, format = splitext(path) format = format[1:] im.format = format.lower() im.save(filename=path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_save_to'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'im'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '19', '40', '50']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '16'], 'value': 'or'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'im'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '22']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'block', 'children': ['23', '32']}; {'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': '_'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'splitext'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '37', 'type': 'slice', 'children': ['38', '39']}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'colon', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'im'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'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': 'im'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'path'}
Save the image for testing.
def _wf_to_dict(wf): inputs, outputs = _get_wf_inout(wf) out = {"name": _id_to_name(wf.tool["id"]).replace("-", "_"), "inputs": inputs, "outputs": outputs, "steps": [], "subworkflows": [], "requirements": []} for step in wf.steps: inputs, outputs = _get_step_inout(step) inputs, scatter = _organize_step_scatter(step, inputs) if isinstance(step.embedded_tool, cwltool.workflow.Workflow): wf_def = _wf_to_dict(step.embedded_tool) out["subworkflows"].append({"id": wf_def["name"], "definition": wf_def, "inputs": inputs, "outputs": outputs, "scatter": scatter}) else: task_def = _tool_to_dict(step.embedded_tool) out["steps"].append({"task_id": task_def["name"], "task_definition": task_def, "inputs": inputs, "outputs": outputs, "scatter": scatter}) return out
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_wf_to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'wf'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '50', '160']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_get_wf_inout'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'wf'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '18', 'type': 'dictionary', 'children': ['19', '35', '38', '41', '44', '47']}; {'id': '19', 'type': 'pair', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '21', 'type': 'call', 'children': ['22', '32']}; {'id': '22', 'type': 'attribute', 'children': ['23', '31']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_id_to_name'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'subscript', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'wf'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'tool'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"-"'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"_"'}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"inputs"'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '38', 'type': 'pair', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"outputs"'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '41', 'type': 'pair', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"steps"'}; {'id': '43', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '44', 'type': 'pair', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': '"subworkflows"'}; {'id': '46', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '47', 'type': 'pair', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"requirements"'}; {'id': '49', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '50', 'type': 'for_statement', 'children': ['51', '52', '55']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'wf'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'steps'}; {'id': '55', 'type': 'block', 'children': ['56', '65', '75']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '61']}; {'id': '58', 'type': 'pattern_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_get_step_inout'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}; {'id': '67', 'type': 'pattern_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'scatter'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_organize_step_scatter'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '75', 'type': 'if_statement', 'children': ['76', '87', '123']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'embedded_tool'}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'cwltool'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'workflow'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'Workflow'}; {'id': '87', 'type': 'block', 'children': ['88', '97']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'wf_def'}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_wf_to_dict'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'embedded_tool'}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '104']}; {'id': '99', 'type': 'attribute', 'children': ['100', '103']}; {'id': '100', 'type': 'subscript', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '102', 'type': 'string', 'children': [], 'value': '"subworkflows"'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'dictionary', 'children': ['106', '111', '114', '117', '120']}; {'id': '106', 'type': 'pair', 'children': ['107', '108']}; {'id': '107', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '108', 'type': 'subscript', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'wf_def'}; {'id': '110', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '111', 'type': 'pair', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': '"definition"'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'wf_def'}; {'id': '114', 'type': 'pair', 'children': ['115', '116']}; {'id': '115', 'type': 'string', 'children': [], 'value': '"inputs"'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '117', 'type': 'pair', 'children': ['118', '119']}; {'id': '118', 'type': 'string', 'children': [], 'value': '"outputs"'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '120', 'type': 'pair', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': '"scatter"'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'scatter'}; {'id': '123', 'type': 'else_clause', 'children': ['124']}; {'id': '124', 'type': 'block', 'children': ['125', '134']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'assignment', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'task_def'}; {'id': '128', 'type': 'call', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': '_tool_to_dict'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'embedded_tool'}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '141']}; {'id': '136', 'type': 'attribute', 'children': ['137', '140']}; {'id': '137', 'type': 'subscript', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '139', 'type': 'string', 'children': [], 'value': '"steps"'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'dictionary', 'children': ['143', '148', '151', '154', '157']}; {'id': '143', 'type': 'pair', 'children': ['144', '145']}; {'id': '144', 'type': 'string', 'children': [], 'value': '"task_id"'}; {'id': '145', 'type': 'subscript', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'task_def'}; {'id': '147', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '148', 'type': 'pair', 'children': ['149', '150']}; {'id': '149', 'type': 'string', 'children': [], 'value': '"task_definition"'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'task_def'}; {'id': '151', 'type': 'pair', 'children': ['152', '153']}; {'id': '152', 'type': 'string', 'children': [], 'value': '"inputs"'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '154', 'type': 'pair', 'children': ['155', '156']}; {'id': '155', 'type': 'string', 'children': [], 'value': '"outputs"'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '157', 'type': 'pair', 'children': ['158', '159']}; {'id': '158', 'type': 'string', 'children': [], 'value': '"scatter"'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'scatter'}; {'id': '160', 'type': 'return_statement', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'out'}
Parse a workflow into cwl2wdl style dictionary.
def send_root_file(self, filename): cache_timeout = self.get_send_file_max_age(filename) return send_from_directory(self.config['ROOT_FOLDER'], filename, cache_timeout=cache_timeout)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_root_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'cache_timeout'}; {'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': 'get_send_file_max_age'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'send_from_directory'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '25', '26']}; {'id': '20', 'type': 'subscript', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'ROOT_FOLDER'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cache_timeout'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cache_timeout'}
Function used to send static files from the root of the domain.
def quantile(image, q, nonzero=True): img_arr = image.numpy() if isinstance(q, (list,tuple)): q = [qq*100. if qq <= 1. else qq for qq in q] if nonzero: img_arr = img_arr[img_arr>0] vals = [np.percentile(img_arr, qq) for qq in q] return tuple(vals) elif isinstance(q, (float,int)): if q <= 1.: q = q*100. if nonzero: img_arr = img_arr[img_arr>0] return np.percentile(img_arr[img_arr>0], q) else: raise ValueError('q argument must be list/tuple or float/int')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'quantile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '18']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'if_statement', 'children': ['19', '26', '72', '115']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '26', 'type': 'block', 'children': ['27', '42', '53', '67']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '30', 'type': 'list_comprehension', 'children': ['31', '39']}; {'id': '31', 'type': 'conditional_expression', 'children': ['32', '35', '38'], 'value': 'if'}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '*'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'qq'}; {'id': '34', 'type': 'float', 'children': [], 'value': '100.'}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': '<='}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'qq'}; {'id': '37', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'qq'}; {'id': '39', 'type': 'for_in_clause', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'qq'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': '>'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '56', 'type': 'list_comprehension', 'children': ['57', '64']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'percentile'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'qq'}; {'id': '64', 'type': 'for_in_clause', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'qq'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '72', 'type': 'elif_clause', 'children': ['73', '80']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '77', 'type': 'tuple', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '80', 'type': 'block', 'children': ['81', '92', '103']}; {'id': '81', 'type': 'if_statement', 'children': ['82', '85']}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '84'], 'value': '<='}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '84', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '89', 'type': 'binary_operator', 'children': ['90', '91'], 'value': '*'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '91', 'type': 'float', 'children': [], 'value': '100.'}; {'id': '92', 'type': 'if_statement', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '100', 'type': 'comparison_operator', 'children': ['101', '102'], 'value': '>'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'percentile'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '114']}; {'id': '109', 'type': 'subscript', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '111', 'type': 'comparison_operator', 'children': ['112', '113'], 'value': '>'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'img_arr'}; {'id': '113', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '115', 'type': 'else_clause', 'children': ['116']}; {'id': '116', 'type': 'block', 'children': ['117']}; {'id': '117', 'type': 'raise_statement', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'string', 'children': [], 'value': "'q argument must be list/tuple or float/int'"}
Get the quantile values from an ANTsImage
def _affine_inv_mult(c, m): "Applies the inverse affine transform described in `m` to `c`." size = c.flow.size() h,w = c.size m[0,1] *= h/w m[1,0] *= w/h c.flow = c.flow.view(-1,2) a = torch.inverse(m[:2,:2].t()) c.flow = torch.mm(c.flow - m[:2,2], a).view(size) return c
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_affine_inv_mult'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '19', '27', '36', '45', '60', '80', '106']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Applies the inverse affine transform described in `m` to `c`."'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'augmented_assignment', 'children': ['29', '33'], 'value': '*='}; {'id': '29', 'type': 'subscript', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '/'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'augmented_assignment', 'children': ['38', '42'], 'value': '*='}; {'id': '38', 'type': 'subscript', 'children': ['39', '40', '41']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '/'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '59']}; {'id': '57', 'type': 'unary_operator', 'children': ['58'], 'value': '-'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'torch'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'inverse'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '79']}; {'id': '69', 'type': 'attribute', 'children': ['70', '78']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72', '75']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '72', 'type': 'slice', 'children': ['73', '74']}; {'id': '73', 'type': 'colon', 'children': []}; {'id': '74', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '75', 'type': 'slice', 'children': ['76', '77']}; {'id': '76', 'type': 'colon', 'children': []}; {'id': '77', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '79', 'type': 'argument_list', 'children': []}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '85', 'type': 'call', 'children': ['86', '104']}; {'id': '86', 'type': 'attribute', 'children': ['87', '103']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'torch'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'mm'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '102']}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '96'], 'value': '-'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '96', 'type': 'subscript', 'children': ['97', '98', '101']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '98', 'type': 'slice', 'children': ['99', '100']}; {'id': '99', 'type': 'colon', 'children': []}; {'id': '100', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'c'}
Applies the inverse affine transform described in `m` to `c`.
def extern_store_f64(self, context_handle, f64): c = self._ffi.from_handle(context_handle) return c.to_value(f64)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extern_store_f64'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'context_handle'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'f64'}; {'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': 'c'}; {'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': '_ffi'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'from_handle'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'context_handle'}; {'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': 'c'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'to_value'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'f64'}
Given a context and double, return a new Handle to represent the double.
def lastChild(self): ret = libxml2mod.xmlGetLastChild(self._o) if ret is None:raise treeError('xmlGetLastChild() failed') __tmp = xmlNode(_obj=ret) return __tmp
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lastChild'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '27', '36']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'libxml2mod'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'xmlGetLastChild'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_o'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'is'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '20', 'type': 'None', 'children': []}; {'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': 'treeError'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'xmlGetLastChild() failed'"}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__tmp'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'xmlNode'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_obj'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '__tmp'}
Search the last child of a node.
def duration(self): self._duration = self.lib.iperf_get_test_duration(self._test) return self._duration
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'duration'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'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': '_duration'}; {'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': 'lib'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'iperf_get_test_duration'}; {'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': '_test'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_duration'}
The test duration in seconds.
def generate_url(self, suffix): url_base_path = os.path.dirname(self.path) netloc = "{}:{}".format(*self.server.server_address) return urlunparse(( "http", netloc, url_base_path + "/" + suffix, "", "", ""))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '34']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'url_base_path'}; {'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': 'os'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'netloc'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"{}:{}"'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'list_splat', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'server_address'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'urlunparse'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'tuple', 'children': ['39', '40', '41', '46', '47', '48']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"http"'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'netloc'}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '45'], 'value': '+'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '+'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'url_base_path'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '46', 'type': 'string', 'children': [], 'value': '""'}; {'id': '47', 'type': 'string', 'children': [], 'value': '""'}; {'id': '48', 'type': 'string', 'children': [], 'value': '""'}
Return URL by combining server details with a path suffix.
def _solve(self): while len(self._remove_constr) > 0: self._remove_constr.pop().delete() try: self._prob.solve(lp.ObjectiveSense.Maximize) except lp.SolverError as e: raise_from(FluxBalanceError('Failed to solve: {}'.format( e), result=self._prob.result), e) finally: self._remove_constr = self._temp_constr self._temp_constr = []
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_solve'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '28']}; {'id': '6', 'type': 'while_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '14'], 'value': '>'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_remove_constr'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '27']}; {'id': '18', 'type': 'attribute', 'children': ['19', '26']}; {'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': '_remove_constr'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'try_statement', 'children': ['29', '43', '72']}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_prob'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'solve'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'lp'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ObjectiveSense'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Maximize'}; {'id': '43', 'type': 'except_clause', 'children': ['44', '50']}; {'id': '44', 'type': 'as_pattern', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'lp'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'SolverError'}; {'id': '48', 'type': 'as_pattern_target', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'e'}; {'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': 'raise_from'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '71']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'FluxBalanceError'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '64']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'Failed to solve: {}'"}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_prob'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '72', 'type': 'finally_clause', 'children': ['73']}; {'id': '73', 'type': 'block', 'children': ['74', '82']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_remove_constr'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': '_temp_constr'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_temp_constr'}; {'id': '87', 'type': 'list', 'children': [], 'value': '[]'}
Solve the problem with the current objective.
def delete_token(): username = get_admin()[0] admins = get_couchdb_admins() if username in admins: print 'I delete {} CouchDB user'.format(username) delete_couchdb_admin(username) if os.path.isfile(LOGIN_FILENAME): print 'I delete {} token file'.format(LOGIN_FILENAME) os.remove(LOGIN_FILENAME)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_token'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '19', '36']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'get_admin'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'admins'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_couchdb_admins'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'in'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'admins'}; {'id': '23', 'type': 'block', 'children': ['24', '31']}; {'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': "'I delete {} CouchDB user'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'delete_couchdb_admin'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '45']}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'LOGIN_FILENAME'}; {'id': '45', 'type': 'block', 'children': ['46', '53']}; {'id': '46', 'type': 'print_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'I delete {} token file'"}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'LOGIN_FILENAME'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'LOGIN_FILENAME'}
Delete current token, file & CouchDB admin user
def plotnoise(noisepkl, mergepkl, plot_width=950, plot_height=400): d = pickle.load(open(mergepkl)) ndist, imstd, flagfrac = plotnoisedist(noisepkl, plot_width=plot_width/2, plot_height=plot_height) fluxscale = calcfluxscale(d, imstd, flagfrac) logger.info('Median image noise is {0:.3} Jy.'.format(fluxscale*imstd)) ncum, imnoise = plotnoisecum(noisepkl, fluxscale=fluxscale, plot_width=plot_width/2, plot_height=plot_height) hndle = show(Row(ndist, ncum, width=plot_width, height=plot_height)) return imnoise
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plotnoise'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'noisepkl'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mergepkl'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'plot_width'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '950'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'plot_height'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '400'}; {'id': '12', 'type': 'block', 'children': ['13', '25', '43', '52', '66', '86', '103']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'mergepkl'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '31']}; {'id': '27', 'type': 'pattern_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ndist'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'imstd'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'flagfrac'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'plotnoisedist'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35', '40']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'noisepkl'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'plot_width'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '/'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'plot_width'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'plot_height'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'plot_height'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fluxscale'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'calcfluxscale'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50', '51']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'imstd'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'flagfrac'}; {'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': 'logger'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'Median image noise is {0:.3} Jy.'"}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '*'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'fluxscale'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'imstd'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '71']}; {'id': '68', 'type': 'pattern_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ncum'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'imnoise'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'plotnoisecum'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75', '78', '83']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'noisepkl'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'fluxscale'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'fluxscale'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'plot_width'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '82'], 'value': '/'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'plot_width'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'plot_height'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'plot_height'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'hndle'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'show'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'Row'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96', '97', '100']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ndist'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'ncum'}; {'id': '97', 'type': 'keyword_argument', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'plot_width'}; {'id': '100', 'type': 'keyword_argument', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'plot_height'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'imnoise'}
Make two panel plot to summary noise analysis with estimated flux scale
def _Members(self, group): group.members = set(group.members).union(self.gids.get(group.gid, [])) return group
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_Members'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '6', 'type': 'block', 'children': ['7', '33']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'members'}; {'id': '12', 'type': 'call', 'children': ['13', '21']}; {'id': '13', 'type': 'attribute', 'children': ['14', '20']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'members'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'union'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'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': 'gids'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'gid'}; {'id': '32', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'group'}
Unify members of a group and accounts with the group as primary gid.