code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def _message(self):
filepath = self._record.file_path
try:
return load_message(filepath)
except FileNotFoundError:
expire_file(filepath)
empty = email.message.Message()
empty.set_payload('')
return empty
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_message'}; {'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', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'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': '_record'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '14', 'type': 'try_statement', 'children': ['15', '21']}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'load_message'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '21', 'type': 'except_clause', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'FileNotFoundError'}; {'id': '23', 'type': 'block', 'children': ['24', '29', '39', '46']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'expire_file'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'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': 'email'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Message'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'set_payload'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "''"}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'empty'}
|
get the message payload
|
def _Register(self, conditions, callback):
for condition in conditions:
registered = self._registry.setdefault(condition, [])
if callback and callback not in registered:
registered.append(callback)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_Register'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'conditions'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'condition'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'conditions'}; {'id': '11', 'type': 'block', 'children': ['12', '24']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'registered'}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_registry'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'condition'}; {'id': '23', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '30']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '27'], 'value': 'and'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'not in'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'registered'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'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': 'registered'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'callback'}
|
Map functions that should be called if the condition applies.
|
def _random(cls):
pid = os.getpid()
if pid != cls._pid:
cls._pid = pid
cls.__random = _random_bytes()
return cls.__random
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_random'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '35']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'getpid'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '20']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '!='}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_pid'}; {'id': '20', 'type': 'block', 'children': ['21', '27']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_pid'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'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': 'cls'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '__random'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_random_bytes'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__random'}
|
Generate a 5-byte random number once per process.
|
def demographics(self):
body = {
"audience_definition": self.audience_definition,
"targeting_inputs": self.targeting_inputs
}
resource = self.RESOURCE_DEMOGRAPHICS.format(account_id=self.account.id)
response = Request(
self.account.client, self.METHOD,
resource, headers=self.HEADERS, body=json.dumps(body)).perform()
return response.body['data']
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'demographics'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '37', '69']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '15']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"audience_definition"'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'audience_definition'}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"targeting_inputs"'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'targeting_inputs'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'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': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'RESOURCE_DEMOGRAPHICS'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'account_id'}; {'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': 'account'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '40', 'type': 'call', 'children': ['41', '68']}; {'id': '41', 'type': 'attribute', 'children': ['42', '67']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Request'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '50', '53', '54', '59']}; {'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': 'account'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'METHOD'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'HEADERS'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'perform'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'data'"}
|
Get the demographic breakdown for an input targeting criteria
|
def augment_cells_no_span(self, rows, source):
return [
[(0, 0, 0, StringList(str(cell).splitlines(), source=source)) for cell in row]
for row in rows
]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'augment_cells_no_span'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '32']}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '29']}; {'id': '11', 'type': 'tuple', 'children': ['12', '13', '14', '15']}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'StringList'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '26']}; {'id': '18', 'type': 'call', 'children': ['19', '25']}; {'id': '19', 'type': 'attribute', 'children': ['20', '24']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '29', 'type': 'for_in_clause', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '32', 'type': 'for_in_clause', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'rows'}
|
Convert each cell into a tuple suitable for consumption by build_table.
|
def reset(self):
self.current_table = None
self.tables = []
self.data = [{}]
self.additional_data = {}
self.lines = []
self.set_state('document')
self.current_file = None
self.set_of_energies = set()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '25', '31', '37', '44', '50']}; {'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': 'current_table'}; {'id': '11', 'type': 'None', 'children': []}; {'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': 'tables'}; {'id': '17', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '23', 'type': 'list', 'children': ['24'], 'value': '[{}]'}; {'id': '24', 'type': 'dictionary', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'additional_data'}; {'id': '30', 'type': 'dictionary', 'children': []}; {'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': 'lines'}; {'id': '36', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'set_state'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'document'"}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'current_file'}; {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'set_of_energies'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '57', 'type': 'argument_list', 'children': []}
|
Clean any processing data, and prepare object for reuse
|
def _scale_cores_to_memory(cores, mem_per_core, sysinfo, system_memory):
total_mem = "%.2f" % (cores * mem_per_core + system_memory)
if "cores" not in sysinfo:
return cores, total_mem, 1.0
total_mem = min(float(total_mem), float(sysinfo["memory"]) - system_memory)
cores = min(cores, int(sysinfo["cores"]))
mem_cores = int(math.floor(float(total_mem) / mem_per_core))
if mem_cores < 1:
out_cores = 1
elif mem_cores < cores:
out_cores = mem_cores
else:
out_cores = cores
mem_pct = float(out_cores) / float(cores)
return out_cores, total_mem, mem_pct
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_scale_cores_to_memory'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mem_per_core'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sysinfo'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'system_memory'}; {'id': '8', 'type': 'block', 'children': ['9', '20', '30', '48', '61', '78', '102', '114']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'total_mem'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '14'], 'value': '%'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"%.2f"'}; {'id': '14', 'type': '()', 'children': ['15']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '19'], 'value': '+'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '*'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'mem_per_core'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'system_memory'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': 'not in'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"cores"'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sysinfo'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'expression_list', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'total_mem'}; {'id': '29', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'total_mem'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '40']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'total_mem'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '47'], 'value': '-'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sysinfo'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"memory"'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'system_memory'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sysinfo'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"cores"'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'mem_cores'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'floor'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '77'], 'value': '/'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'total_mem'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'mem_per_core'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '82', '87', '96']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '81'], 'value': '<'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'mem_cores'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'out_cores'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '87', 'type': 'elif_clause', 'children': ['88', '91']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '90'], 'value': '<'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'mem_cores'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'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': 'out_cores'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'mem_cores'}; {'id': '96', 'type': 'else_clause', 'children': ['97']}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'out_cores'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'mem_pct'}; {'id': '105', 'type': 'binary_operator', 'children': ['106', '110'], 'value': '/'}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'out_cores'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'cores'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'expression_list', 'children': ['116', '117', '118']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'out_cores'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'total_mem'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'mem_pct'}
|
Scale multicore usage to avoid excessive memory usage based on system information.
|
def do_read(self, args):
if not self.current:
print('There are no resources in use. Use the command "open".')
return
try:
print(self.current.read())
except Exception as e:
print(e)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '12']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '12', 'type': 'block', 'children': ['13', '18']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': '\'There are no resources in use. Use the command "open".\''}; {'id': '18', 'type': 'return_statement', 'children': []}; {'id': '19', 'type': 'try_statement', 'children': ['20', '32']}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'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': 'current'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'except_clause', 'children': ['33', '37']}; {'id': '33', 'type': 'as_pattern', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '35', 'type': 'as_pattern_target', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'e'}
|
Receive from the resource in use.
|
def sync_entities_watching(instance):
for entity_model, entity_model_getter in entity_registry.entity_watching[instance.__class__]:
model_objs = list(entity_model_getter(instance))
if model_objs:
sync_entities(*model_objs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sync_entities_watching'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '17']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'entity_model'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'entity_model_getter'}; {'id': '10', 'type': 'subscript', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'entity_registry'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'entity_watching'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '17', 'type': 'block', 'children': ['18', '28']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'model_objs'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'entity_model_getter'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'model_objs'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sync_entities'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'list_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'model_objs'}
|
Syncs entities watching changes of a model instance.
|
def _do_report(self, report, in_port, msg):
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
size = 65535
else:
size = ofproto.OFPCML_MAX
update = False
self._mcast.setdefault(report.address, {})
if in_port not in self._mcast[report.address]:
update = True
self._mcast[report.address][in_port] = True
if update:
actions = []
for port in self._mcast[report.address]:
actions.append(parser.OFPActionOutput(port))
self._set_flow_entry(
datapath, actions, self.server_port, report.address)
self._set_flow_entry(
datapath,
[parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, size)],
in_port, report.address)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_do_report'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'in_port'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '21', '27', '48', '52', '64', '79', '91']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'datapath'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'datapath'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ofproto'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'datapath'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ofproto'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'datapath'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ofproto_parser'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '35', '40']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': '=='}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ofproto'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'OFP_VERSION'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ofproto_v1_0'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'OFP_VERSION'}; {'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': 'size'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '65535'}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ofproto'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'OFPCML_MAX'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '51', 'type': 'False', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'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': '_mcast'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '63', 'type': 'dictionary', 'children': []}; {'id': '64', 'type': 'if_statement', 'children': ['65', '74']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': 'not in'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'in_port'}; {'id': '67', 'type': 'subscript', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_mcast'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '78', 'type': 'True', 'children': []}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '90']}; {'id': '81', 'type': 'subscript', 'children': ['82', '89']}; {'id': '82', 'type': 'subscript', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': '_mcast'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'in_port'}; {'id': '90', 'type': 'True', 'children': []}; {'id': '91', 'type': 'if_statement', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '93', 'type': 'block', 'children': ['94', '98', '120', '134']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '97', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '98', 'type': 'for_statement', 'children': ['99', '100', '107']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'port'}; {'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': '_mcast'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'OFPActionOutput'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'port'}; {'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': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': '_set_flow_entry'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '127', '128', '131']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'datapath'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'server_port'}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': '_set_flow_entry'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141', '151', '152']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'datapath'}; {'id': '141', 'type': 'list', 'children': ['142'], 'value': '[parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, size)]'}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'OFPActionOutput'}; {'id': '146', 'type': 'argument_list', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'ofproto'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'OFPP_CONTROLLER'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'in_port'}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'report'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'address'}
|
the process when the querier received a REPORT message.
|
def execute_ls(host_list, remote_user, remote_pass):
runner = spam.ansirunner.AnsibleRunner()
result, failed_hosts = runner.ansible_perform_operation(
host_list=host_list,
remote_user=remote_user,
remote_pass=remote_pass,
module="command",
module_args="ls -1")
print "Result: ", result
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute_ls'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'host_list'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'remote_user'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'remote_pass'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '43']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'runner'}; {'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': 'spam'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ansirunner'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'AnsibleRunner'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'failed_hosts'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'runner'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ansible_perform_operation'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31', '34', '37', '40']}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'host_list'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'host_list'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'remote_user'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'remote_user'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'remote_pass'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'remote_pass'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"command"'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'module_args'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"ls -1"'}; {'id': '43', 'type': 'print_statement', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"Result: "'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'result'}
|
Execute any adhoc command on the hosts.
|
def transform(self, X):
if not self.is_fit:
raise ValueError("The scaler has not been fit yet.")
return (X-self.mean) / (self.std + 10e-7)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transform'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '6', 'type': 'block', 'children': ['7', '18']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '12']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'is_fit'}; {'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': 'ValueError'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"The scaler has not been fit yet."'}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '26'], 'value': '/'}; {'id': '20', 'type': '()', 'children': ['21']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '-'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '26', 'type': '()', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '31'], 'value': '+'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'std'}; {'id': '31', 'type': 'float', 'children': [], 'value': '10e-7'}
|
Transform your data to zero mean unit variance.
|
def apply_substitutions(monomial, monomial_substitutions, pure=False):
if is_number_type(monomial):
return monomial
original_monomial = monomial
changed = True
if not pure:
substitutions = monomial_substitutions
else:
substitutions = {}
for lhs, rhs in monomial_substitutions.items():
irrelevant = False
for atom in lhs.atoms():
if atom.is_Number:
continue
if not monomial.has(atom):
irrelevant = True
break
if not irrelevant:
substitutions[lhs] = rhs
while changed:
for lhs, rhs in substitutions.items():
monomial = fast_substitute(monomial, lhs, rhs)
if original_monomial == monomial:
changed = False
original_monomial = monomial
return monomial
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply_substitutions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'monomial_substitutions'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'pure'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '18', '22', '26', '92', '127']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '15']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'is_number_type'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'original_monomial'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'changed'}; {'id': '25', 'type': 'True', 'children': []}; {'id': '26', 'type': 'if_statement', 'children': ['27', '29', '34']}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pure'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'substitutions'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'monomial_substitutions'}; {'id': '34', 'type': 'else_clause', 'children': ['35']}; {'id': '35', 'type': 'block', 'children': ['36', '40']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'substitutions'}; {'id': '39', 'type': 'dictionary', 'children': []}; {'id': '40', 'type': 'for_statement', 'children': ['41', '44', '49']}; {'id': '41', 'type': 'pattern_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'monomial_substitutions'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50', '54', '82']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'irrelevant'}; {'id': '53', 'type': 'False', 'children': []}; {'id': '54', 'type': 'for_statement', 'children': ['55', '56', '61']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'atom'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'atoms'}; {'id': '60', 'type': 'argument_list', 'children': []}; {'id': '61', 'type': 'block', 'children': ['62', '68']}; {'id': '62', 'type': 'if_statement', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'atom'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'is_Number'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'continue_statement', 'children': []}; {'id': '68', 'type': 'if_statement', 'children': ['69', '76']}; {'id': '69', 'type': 'not_operator', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'has'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'atom'}; {'id': '76', 'type': 'block', 'children': ['77', '81']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'irrelevant'}; {'id': '80', 'type': 'True', 'children': []}; {'id': '81', 'type': 'break_statement', 'children': []}; {'id': '82', 'type': 'if_statement', 'children': ['83', '85']}; {'id': '83', 'type': 'not_operator', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'irrelevant'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '91']}; {'id': '88', 'type': 'subscript', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'substitutions'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '92', 'type': 'while_statement', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'changed'}; {'id': '94', 'type': 'block', 'children': ['95', '114', '123']}; {'id': '95', 'type': 'for_statement', 'children': ['96', '99', '104']}; {'id': '96', 'type': 'pattern_list', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'substitutions'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '103', 'type': 'argument_list', 'children': []}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'fast_substitute'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '112', '113']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '114', 'type': 'if_statement', 'children': ['115', '118']}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': '=='}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'original_monomial'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'changed'}; {'id': '122', 'type': 'False', 'children': []}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'original_monomial'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'monomial'}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'monomial'}
|
Helper function to remove monomials from the basis.
|
def put_value(self, value, timeout=None):
self._context.put(self._data.path + ["value"], value, timeout=timeout)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_context'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '26', '27']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '24'], 'value': '+'}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_data'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'list', 'children': ['25'], 'value': '["value"]'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'timeout'}
|
Put a value to the Attribute and wait for completion
|
def ast_from_module(self, module, modname=None):
modname = modname or module.__name__
if modname in self.astroid_cache:
return self.astroid_cache[modname]
try:
filepath = module.__file__
if modutils.is_python_source(filepath):
return self.ast_from_file(filepath, modname)
except AttributeError:
pass
from astroid.builder import AstroidBuilder
return AstroidBuilder(self).module_build(module, modname)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ast_from_module'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'modname'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '18', '31', '59', '65']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'modname'}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '15'], 'value': 'or'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'modname'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '24']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'in'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'modname'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'astroid_cache'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'subscript', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'astroid_cache'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'modname'}; {'id': '31', 'type': 'try_statement', 'children': ['32', '55']}; {'id': '32', 'type': 'block', 'children': ['33', '39']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__file__'}; {'id': '39', 'type': 'if_statement', 'children': ['40', '46']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'modutils'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'is_python_source'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ast_from_file'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'modname'}; {'id': '55', 'type': 'except_clause', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'pass_statement', 'children': []}; {'id': '59', 'type': 'import_from_statement', 'children': ['60', '63']}; {'id': '60', 'type': 'dotted_name', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'astroid'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '63', 'type': 'dotted_name', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'AstroidBuilder'}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '73']}; {'id': '67', 'type': 'attribute', 'children': ['68', '72']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'AstroidBuilder'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'module_build'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'modname'}
|
given an imported module, return the astroid object
|
def update(self):
vehicle = self.api.vehicles(vid=self.vid)['vehicle']
newbus = self.fromapi(self.api, vehicle)
self.__dict__ = newbus.__dict__
del newbus
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '23', '35', '43']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'vehicle'}; {'id': '9', 'type': 'subscript', 'children': ['10', '22']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'vehicles'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'vid'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'vid'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'vehicle'"}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'newbus'}; {'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': 'fromapi'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'vehicle'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'newbus'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '43', 'type': 'delete_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'newbus'}
|
Update this bus by creating a new one and transplanting dictionaries.
|
def parse_value(self, sn: "DataNode") -> ScalarValue:
res = sn.type.parse_value(self.value)
if res is None:
raise InvalidKeyValue(self.value)
return res
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sn'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"DataNode"'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ScalarValue'}; {'id': '11', 'type': 'block', 'children': ['12', '25', '37']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sn'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'parse_value'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'raise_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'InvalidKeyValue'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'res'}
|
Let schema node's type parse the receiver's value.
|
def Preprocess(self, data):
data = data.replace(":\\", ": \\")
data = SudoersFieldParser.COMMENTS_RE.sub("", data)
return data
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Preprocess'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '29']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '":\\\\"'}; {'id': '16', 'type': 'string', 'children': [], 'value': '": \\\\"'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data'}; {'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': 'SudoersFieldParser'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'COMMENTS_RE'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '""'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}
|
Preprocess the given data, ready for parsing.
|
def post(self, url, body=None):
response = self.http.post(url,
headers=self.headers,
data=body,
**self.requests_params)
return self.process(response)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '33']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'response'}; {'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': 'http'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '26', '29']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '29', 'type': 'dictionary_splat', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'requests_params'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'response'}
|
Executes an HTTP POST request for the given URL.
|
def show_network(self, network, **_params):
return self.get(self.network_path % (network), params=_params)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_network'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': '_params'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '21']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '19'], 'value': '%'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'network_path'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_params'}
|
Fetches information of a certain network.
|
def _read_interleaved_numpy(self, f, data_objects):
log.debug("Reading interleaved data all at once")
all_channel_bytes = data_objects[0].raw_data_width
if all_channel_bytes == 0:
all_channel_bytes = sum((o.data_type.size for o in data_objects))
log.debug("all_channel_bytes: %d", all_channel_bytes)
number_bytes = int(all_channel_bytes * data_objects[0].number_values)
combined_data = fromfile(f, dtype=np.uint8, count=number_bytes)
combined_data = combined_data.reshape(-1, all_channel_bytes)
data_pos = 0
for (i, obj) in enumerate(data_objects):
byte_columns = tuple(
range(data_pos, obj.data_type.size + data_pos))
log.debug("Byte columns for channel %d: %s", i, byte_columns)
object_data = combined_data[:, byte_columns].ravel()
object_data.dtype = (
np.dtype(obj.data_type.nptype).newbyteorder(self.endianness))
obj.tdms_object._update_data(object_data)
data_pos += obj.data_type.size
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_interleaved_numpy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data_objects'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '23', '43', '51', '64', '79', '90', '94']}; {'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': 'log'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"Reading interleaved data all at once"'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'all_channel_bytes'}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data_objects'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'raw_data_width'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': '=='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'all_channel_bytes'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'all_channel_bytes'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'generator_expression', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '40', 'type': 'for_in_clause', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'data_objects'}; {'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': 'log'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': '"all_channel_bytes: %d"'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'all_channel_bytes'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'number_bytes'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '*'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'all_channel_bytes'}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'data_objects'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'number_values'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'combined_data'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'fromfile'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71', '76']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'uint8'}; {'id': '76', 'type': 'keyword_argument', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'number_bytes'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'combined_data'}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'combined_data'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'reshape'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '89']}; {'id': '87', 'type': 'unary_operator', 'children': ['88'], 'value': '-'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'all_channel_bytes'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'data_pos'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '94', 'type': 'for_statement', 'children': ['95', '98', '102']}; {'id': '95', 'type': 'tuple_pattern', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '98', 'type': 'call', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'data_objects'}; {'id': '102', 'type': 'block', 'children': ['103', '120', '129', '141', '164', '173']}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'byte_columns'}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '111', 'type': 'argument_list', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'data_pos'}; {'id': '113', 'type': 'binary_operator', 'children': ['114', '119'], 'value': '+'}; {'id': '114', 'type': 'attribute', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'data_pos'}; {'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': 'log'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '127', '128']}; {'id': '126', 'type': 'string', 'children': [], 'value': '"Byte columns for channel %d: %s"'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'byte_columns'}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'object_data'}; {'id': '132', 'type': 'call', 'children': ['133', '140']}; {'id': '133', 'type': 'attribute', 'children': ['134', '139']}; {'id': '134', 'type': 'subscript', 'children': ['135', '136', '138']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'combined_data'}; {'id': '136', 'type': 'slice', 'children': ['137']}; {'id': '137', 'type': 'colon', 'children': []}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'byte_columns'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'ravel'}; {'id': '140', 'type': 'argument_list', 'children': []}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'object_data'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '146', 'type': '()', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '160']}; {'id': '148', 'type': 'attribute', 'children': ['149', '159']}; {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'attribute', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'nptype'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'newbyteorder'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'endianness'}; {'id': '164', 'type': 'expression_statement', 'children': ['165']}; {'id': '165', 'type': 'call', 'children': ['166', '171']}; {'id': '166', 'type': 'attribute', 'children': ['167', '170']}; {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'tdms_object'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': '_update_data'}; {'id': '171', 'type': 'argument_list', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'object_data'}; {'id': '173', 'type': 'expression_statement', 'children': ['174']}; {'id': '174', 'type': 'augmented_assignment', 'children': ['175', '176'], 'value': '+='}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'data_pos'}; {'id': '176', 'type': 'attribute', 'children': ['177', '180']}; {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'size'}
|
Read interleaved data where all channels have a numpy type
|
def exvp(pos_x, pos_y):
pos_x = numpy.asarray(pos_x)
pos_y = numpy.asarray(pos_y)
center = [1024.5, 1024.5]
cf = EMIR_PLATESCALE_RADS
pos_base_x = pos_x - center[0]
pos_base_y = pos_y - center[1]
ra = numpy.hypot(pos_base_x, pos_base_y)
thet = numpy.arctan2(pos_base_y, pos_base_x)
r = cf * ra
rr1 = 1 + 14606.7 * r**2 + 1739716115.1 * r**4
nx1 = rr1 * ra * numpy.cos(thet) + center[0]
ny1 = rr1 * ra * numpy.sin(thet) + center[1]
return nx1, ny1
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exvp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pos_x'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pos_y'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '31', '35', '43', '51', '61', '71', '77', '93', '110', '127']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pos_x'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pos_x'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pos_y'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pos_y'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'center'}; {'id': '28', 'type': 'list', 'children': ['29', '30'], 'value': '[1024.5, 1024.5]'}; {'id': '29', 'type': 'float', 'children': [], 'value': '1024.5'}; {'id': '30', 'type': 'float', 'children': [], 'value': '1024.5'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cf'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'EMIR_PLATESCALE_RADS'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pos_base_x'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '-'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'pos_x'}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'center'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'pos_base_y'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '-'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'pos_y'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'center'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ra'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'hypot'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pos_base_x'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pos_base_y'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'thet'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'arctan2'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pos_base_y'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pos_base_x'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '76'], 'value': '*'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'cf'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ra'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'rr1'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '88'], 'value': '+'}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '83'], 'value': '+'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '*'}; {'id': '84', 'type': 'float', 'children': [], 'value': '14606.7'}; {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '**'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '*'}; {'id': '89', 'type': 'float', 'children': [], 'value': '1739716115.1'}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '92'], 'value': '**'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'nx1'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '107'], 'value': '+'}; {'id': '97', 'type': 'binary_operator', 'children': ['98', '101'], 'value': '*'}; {'id': '98', 'type': 'binary_operator', 'children': ['99', '100'], 'value': '*'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'rr1'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ra'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'thet'}; {'id': '107', 'type': 'subscript', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'center'}; {'id': '109', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'ny1'}; {'id': '113', 'type': 'binary_operator', 'children': ['114', '124'], 'value': '+'}; {'id': '114', 'type': 'binary_operator', 'children': ['115', '118'], 'value': '*'}; {'id': '115', 'type': 'binary_operator', 'children': ['116', '117'], 'value': '*'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'rr1'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'ra'}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'thet'}; {'id': '124', 'type': 'subscript', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'center'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'expression_list', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'nx1'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'ny1'}
|
Convert virtual pixel to real pixel
|
def parse(self, filename: str, language: str = None, contents: str = None,
timeout: float = None) -> CompatParseResponse:
return self._parse(filename, language, contents, timeout,
Mode.Value('ANNOTATED'))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '14', '19']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'typed_default_parameter', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'typed_default_parameter', 'children': ['15', '16', '18']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'typed_default_parameter', 'children': ['20', '21', '23']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '21', 'type': 'type', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'type', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'CompatParseResponse'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_parse'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '35', '36', '37']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Mode'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'Value'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'ANNOTATED'"}
|
Parse the specified filename or contents and return a CompatParseResponse.
|
def do_OPTIONS(self):
thread_local.clock_start = get_time()
thread_local.status_code = 200
thread_local.message = None
thread_local.headers = []
thread_local.end_headers = []
thread_local.size = -1
thread_local.method = 'OPTIONS'
self.send_response(200)
if self.is_cross_origin():
no_caching = self.cross_origin_headers()
self.send_header("Access-Control-Max-Age",
0 if no_caching else 10*60)
self.send_header("Content-Length", 0)
self.end_headers()
thread_local.size = 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_OPTIONS'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '20', '26', '32', '38', '45', '51', '58', '86', '94', '100']}; {'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': 'thread_local'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'clock_start'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_time'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'thread_local'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'thread_local'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'thread_local'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '31', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'thread_local'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'end_headers'}; {'id': '37', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'thread_local'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '43', 'type': 'unary_operator', 'children': ['44'], 'value': '-'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'thread_local'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'OPTIONS'"}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'send_response'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '64']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'is_cross_origin'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'block', 'children': ['65', '73']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'no_caching'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'cross_origin_headers'}; {'id': '72', 'type': 'argument_list', 'children': []}; {'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': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'send_header'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"Access-Control-Max-Age"'}; {'id': '80', 'type': 'conditional_expression', 'children': ['81', '82', '83'], 'value': 'if'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'no_caching'}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '*'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'send_header'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'string', 'children': [], 'value': '"Content-Length"'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'end_headers'}; {'id': '99', 'type': 'argument_list', 'children': []}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'thread_local'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '0'}
|
Handles an OPTIONS request.
|
def startElement(self, node):
if node is None:
return
if self.__filter_location is not None:
if node.location.file is None:
return
elif node.location.file.name not in self.__filter_location:
return
log.debug(
'%s:%d: Found a %s|%s|%s',
node.location.file,
node.location.line,
node.kind.name,
node.displayname,
node.spelling)
try:
stop_recurse = self.parse_cursor(node)
if stop_recurse is not False:
return
for child in node.get_children():
self.startElement(child)
except InvalidDefinitionError:
pass
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'startElement'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '44', '72', '108']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': []}; {'id': '13', 'type': 'if_statement', 'children': ['14', '19']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '18'], 'value': 'is not'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__filter_location'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '28', '30']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '27'], 'value': 'is'}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': []}; {'id': '30', 'type': 'elif_clause', 'children': ['31', '42']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '39'], 'value': 'not in'}; {'id': '32', 'type': 'attribute', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '__filter_location'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51', '56', '61', '66', '69']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'%s:%d: Found a %s|%s|%s'"}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'displayname'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'spelling'}; {'id': '72', 'type': 'try_statement', 'children': ['73', '104']}; {'id': '73', 'type': 'block', 'children': ['74', '83', '89']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'stop_recurse'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'parse_cursor'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '83', 'type': 'if_statement', 'children': ['84', '87']}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': 'is not'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'stop_recurse'}; {'id': '86', 'type': 'False', 'children': []}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'return_statement', 'children': []}; {'id': '89', 'type': 'for_statement', 'children': ['90', '91', '96']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'get_children'}; {'id': '95', 'type': 'argument_list', 'children': []}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'startElement'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '104', 'type': 'except_clause', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'InvalidDefinitionError'}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'pass_statement', 'children': []}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'None', 'children': []}
|
Recurses in children of this node
|
def atlasdb_load_peer_table( con=None, path=None ):
peer_table = {}
with AtlasDBOpen(con=con, path=path) as dbcon:
sql = "SELECT * FROM peers;"
args = ()
cur = dbcon.cursor()
res = atlasdb_query_execute( cur, sql, args )
count = 0
for row in res:
if count > 0 and count % 100 == 0:
log.debug("Loaded %s peers..." % count)
atlas_init_peer_info( peer_table, row['peer_hostport'] )
count += 1
return peer_table
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'atlasdb_load_peer_table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '15', '96']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'peer_table'}; {'id': '14', 'type': 'dictionary', 'children': []}; {'id': '15', 'type': 'with_statement', 'children': ['16', '30']}; {'id': '16', 'type': 'with_clause', 'children': ['17']}; {'id': '17', 'type': 'with_item', 'children': ['18']}; {'id': '18', 'type': 'as_pattern', 'children': ['19', '28']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'AtlasDBOpen'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '25']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'as_pattern_target', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dbcon'}; {'id': '30', 'type': 'block', 'children': ['31', '35', '39', '47', '56', '60']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"SELECT * FROM peers;"'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '38', 'type': 'tuple', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dbcon'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'atlasdb_query_execute'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54', '55']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'for_statement', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '63', 'type': 'block', 'children': ['64', '84', '92']}; {'id': '64', 'type': 'if_statement', 'children': ['65', '74']}; {'id': '65', 'type': 'boolean_operator', 'children': ['66', '69'], 'value': 'and'}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '68'], 'value': '>'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '73'], 'value': '=='}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '%'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '83'], 'value': '%'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"Loaded %s peers..."'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'atlas_init_peer_info'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'peer_table'}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'peer_hostport'"}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'augmented_assignment', 'children': ['94', '95'], 'value': '+='}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '95', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'peer_table'}
|
Create a peer table from the peer DB
|
def channels(self):
if self.mf.mode() == mad.MODE_SINGLE_CHANNEL:
return 1
elif self.mf.mode() in (mad.MODE_DUAL_CHANNEL,
mad.MODE_JOINT_STEREO,
mad.MODE_STEREO):
return 2
else:
return 2
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'channels'}; {'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', '18', '21', '43']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '15'], 'value': '=='}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'mf'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'mad'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'MODE_SINGLE_CHANNEL'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '21', 'type': 'elif_clause', 'children': ['22', '40']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '30'], 'value': 'in'}; {'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': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'mf'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'tuple', 'children': ['31', '34', '37']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'mad'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'MODE_DUAL_CHANNEL'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'mad'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'MODE_JOINT_STEREO'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'mad'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'MODE_STEREO'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '43', 'type': 'else_clause', 'children': ['44']}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'integer', 'children': [], 'value': '2'}
|
The number of channels.
|
def display_paths(instances, type_str):
print('%ss: count=%s' % (type_str, len(instances),))
for path in [instance.path for instance in instances]:
print('%s: %s' % (type_str, path))
if len(instances):
print('')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'display_paths'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'type_str'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '38']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '13'], 'value': '%'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'%ss: count=%s'"}; {'id': '13', 'type': 'tuple', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'type_str'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '28']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '%'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'%s: %s'"}; {'id': '35', 'type': 'tuple', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'type_str'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '43']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': "''"}
|
Display the count and paths for the list of instances in instances.
|
def full_installation(self, location=None):
url = ("https://tccna.honeywell.com/WebAPI/emea/api/v1/location"
"/%s/installationInfo?includeTemperatureControlSystems=True"
% self._get_location(location))
response = requests.get(url, headers=self._headers())
response.raise_for_status()
return response.json()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'full_installation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '23', '39', '45']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '12', 'type': '()', 'children': ['13']}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '17'], 'value': '%'}; {'id': '14', 'type': 'concatenated_string', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"https://tccna.honeywell.com/WebAPI/emea/api/v1/location"'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"/%s/installationInfo?includeTemperatureControlSystems=True"'}; {'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': '_get_location'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_headers'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'raise_for_status'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '50', 'type': 'argument_list', 'children': []}
|
Return the full details of the installation.
|
def remove_external_references_from_roles(self):
for node_role in self.node.findall('role'):
role = Crole(node_role)
role.remove_external_references()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_external_references_from_roles'}; {'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', '16']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'node_role'}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'role'"}; {'id': '16', 'type': 'block', 'children': ['17', '24']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Crole'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'node_role'}; {'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': 'role'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'remove_external_references'}; {'id': '29', 'type': 'argument_list', 'children': []}
|
Removes any external references on any of the roles from the predicate
|
def _infer_dict(obj):
for ats in (('__len__', 'get', 'has_key', 'items', 'keys', 'values'),
('__len__', 'get', 'has_key', 'iteritems', 'iterkeys', 'itervalues')):
for a in ats:
if not _callable(getattr(obj, a, None)):
break
else:
return True
return False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_infer_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '5', 'type': 'block', 'children': ['6', '45']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '23']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'ats'}; {'id': '8', 'type': 'tuple', 'children': ['9', '16']}; {'id': '9', 'type': 'tuple', 'children': ['10', '11', '12', '13', '14', '15']}; {'id': '10', 'type': 'string', 'children': [], 'value': "'__len__'"}; {'id': '11', 'type': 'string', 'children': [], 'value': "'get'"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'has_key'"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'items'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "'keys'"}; {'id': '15', 'type': 'string', 'children': [], 'value': "'values'"}; {'id': '16', 'type': 'tuple', 'children': ['17', '18', '19', '20', '21', '22']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'__len__'"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'get'"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'has_key'"}; {'id': '20', 'type': 'string', 'children': [], 'value': "'iteritems'"}; {'id': '21', 'type': 'string', 'children': [], 'value': "'iterkeys'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'itervalues'"}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '27', '41']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ats'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '39']}; {'id': '29', 'type': 'not_operator', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_callable'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'break_statement', 'children': []}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'True', 'children': []}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'False', 'children': []}
|
Return True for likely dict object.
|
def getEyeOutputViewport(self, eEye):
fn = self.function_table.getEyeOutputViewport
pnX = c_uint32()
pnY = c_uint32()
pnWidth = c_uint32()
pnHeight = c_uint32()
fn(eEye, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight))
return pnX.value, pnY.value, pnWidth.value, pnHeight.value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getEyeOutputViewport'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'eEye'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '21', '27', '33', '39', '60']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'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': 'function_table'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'getEyeOutputViewport'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'pnX'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'c_uint32'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pnY'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'c_uint32'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pnWidth'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'c_uint32'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'pnHeight'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'c_uint32'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44', '48', '52', '56']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'eEye'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'byref'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'pnX'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'byref'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'pnY'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'byref'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pnWidth'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'byref'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pnHeight'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'expression_list', 'children': ['62', '65', '68', '71']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'pnX'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'pnY'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pnWidth'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'pnHeight'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Gets the viewport in the frame buffer to draw the output of the distortion into
|
def open_submission(self):
url = self.get_selected_item().get('submission_permalink')
if url:
self.selected_page = self.open_submission_page(url)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open_submission'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'url'}; {'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': 'get_selected_item'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'submission_permalink'"}; {'id': '19', 'type': 'if_statement', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'selected_page'}; {'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': 'open_submission_page'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'url'}
|
Open the full submission and comment tree for the selected comment.
|
def _parse_scram_response(response):
return dict(item.split(b"=", 1) for item in response.split(b","))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_scram_response'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'response'}; {'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': 'dict'}; {'id': '9', 'type': 'generator_expression', 'children': ['10', '17']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': 'b"="'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '17', 'type': 'for_in_clause', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': 'b","'}
|
Split a scram response into key, value pairs.
|
def parse_headers_link(headers):
header = CaseInsensitiveDict(headers).get('link')
l = {}
if header:
links = parse_link(header)
for link in links:
key = link.get('rel') or link.get('url')
l[key] = link
return l
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_headers_link'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '22', '58']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '9', 'type': 'call', 'children': ['10', '16']}; {'id': '10', 'type': 'attribute', 'children': ['11', '15']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'CaseInsensitiveDict'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'link'"}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '21', 'type': 'dictionary', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '24', 'type': 'block', 'children': ['25', '32']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'parse_link'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '35', 'type': 'block', 'children': ['36', '52']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'boolean_operator', 'children': ['40', '46'], 'value': 'or'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'rel'"}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'url'"}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'l'}
|
Returns the parsed header links of the response, if any.
|
def write(settings_path, settings_data, **kwargs):
for key, value in settings_data.items():
dotenv_cli.set_key(str(settings_path), key.upper(), str(value))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'settings_path'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'settings_data'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'for_statement', 'children': ['10', '13', '18']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'settings_data'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'items'}; {'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', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dotenv_cli'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'set_key'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '29', '34']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'settings_path'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Write data to .env file
|
def delete_untagged(collector, **kwargs):
configuration = collector.configuration
docker_api = configuration["harpoon"].docker_api
images = docker_api.images()
found = False
for image in images:
if image["RepoTags"] == ["<none>:<none>"]:
found = True
image_id = image["Id"]
log.info("Deleting untagged image\thash=%s", image_id)
try:
docker_api.remove_image(image["Id"])
except DockerAPIError as error:
log.error("Failed to delete image\thash=%s\terror=%s", image_id, error)
if not found:
log.info("Didn't find any untagged images to delete!")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_untagged'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '22', '30', '34', '90']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'configuration'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'configuration'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'docker_api'}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'configuration'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"harpoon"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'docker_api'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'images'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'docker_api'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'images'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '33', 'type': 'False', 'children': []}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'images'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'if_statement', 'children': ['39', '45']}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '43'], 'value': '=='}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"RepoTags"'}; {'id': '43', 'type': 'list', 'children': ['44'], 'value': '["<none>:<none>"]'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"<none>:<none>"'}; {'id': '45', 'type': 'block', 'children': ['46', '50', '56', '64']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '49', 'type': 'True', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'image_id'}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"Id"'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': '"Deleting untagged image\\thash=%s"'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'image_id'}; {'id': '64', 'type': 'try_statement', 'children': ['65', '75']}; {'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': 'docker_api'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'remove_image'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"Id"'}; {'id': '75', 'type': 'except_clause', 'children': ['76', '80']}; {'id': '76', 'type': 'as_pattern', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'DockerAPIError'}; {'id': '78', 'type': 'as_pattern_target', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88', '89']}; {'id': '87', 'type': 'string', 'children': [], 'value': '"Failed to delete image\\thash=%s\\terror=%s"'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'image_id'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '90', 'type': 'if_statement', 'children': ['91', '93']}; {'id': '91', 'type': 'not_operator', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'string', 'children': [], 'value': '"Didn\'t find any untagged images to delete!"'}
|
Find the untagged images and remove them
|
def keep_only_sticked_and_selected_tabs(self):
if not global_gui_config.get_config_value('KEEP_ONLY_STICKY_STATES_OPEN', True):
return
page_id = self.view.notebook.get_current_page()
if page_id == -1:
return
page = self.view.notebook.get_nth_page(page_id)
current_state_identifier = self.get_state_identifier_for_page(page)
states_to_be_closed = []
for state_identifier, tab_info in list(self.tabs.items()):
if current_state_identifier == state_identifier:
continue
if tab_info['is_sticky']:
continue
states_to_be_closed.append(state_identifier)
for state_identifier in states_to_be_closed:
self.close_page(state_identifier, delete=False)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'keep_only_sticked_and_selected_tabs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '29', '36', '49', '58', '62', '96']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'global_gui_config'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'get_config_value'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'KEEP_ONLY_STICKY_STATES_OPEN'"}; {'id': '14', 'type': 'True', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'page_id'}; {'id': '20', 'type': 'call', 'children': ['21', '28']}; {'id': '21', 'type': 'attribute', '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': 'view'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get_current_page'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'if_statement', 'children': ['30', '34']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '=='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'page_id'}; {'id': '32', 'type': 'unary_operator', 'children': ['33'], 'value': '-'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '39', 'type': 'call', 'children': ['40', '47']}; {'id': '40', 'type': 'attribute', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'get_nth_page'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'page_id'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'current_state_identifier'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'get_state_identifier_for_page'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'states_to_be_closed'}; {'id': '61', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '62', 'type': 'for_statement', 'children': ['63', '66', '76']}; {'id': '63', 'type': 'pattern_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'tab_info'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'tabs'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'block', 'children': ['77', '83', '89']}; {'id': '77', 'type': 'if_statement', 'children': ['78', '81']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '80'], 'value': '=='}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'current_state_identifier'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'continue_statement', 'children': []}; {'id': '83', 'type': 'if_statement', 'children': ['84', '87']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'tab_info'}; {'id': '86', 'type': 'string', 'children': [], 'value': "'is_sticky'"}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'continue_statement', 'children': []}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'states_to_be_closed'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '96', 'type': 'for_statement', 'children': ['97', '98', '99']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'states_to_be_closed'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'close_page'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '107', 'type': 'keyword_argument', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '109', 'type': 'False', 'children': []}
|
Close all tabs, except the currently active one and all sticked ones
|
def request(self, method, url, **kwargs):
self._check_auth()
return super(OAuthAPIClient, self).request(method, url, **kwargs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'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': '_check_auth'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '25']}; {'id': '18', 'type': 'attribute', 'children': ['19', '24']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'OAuthAPIClient'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '28']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '28', 'type': 'dictionary_splat', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Overrides Session.request to ensure that the session is authenticated
|
def bitop_and(self, dest, key, *keys):
return self.execute(b'BITOP', b'AND', dest, key, *keys)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bitop_and'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '7', 'type': 'list_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'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': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '18', '19', '20']}; {'id': '16', 'type': 'string', 'children': [], 'value': "b'BITOP'"}; {'id': '17', 'type': 'string', 'children': [], 'value': "b'AND'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '20', 'type': 'list_splat', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'keys'}
|
Perform bitwise AND operations between strings.
|
def update_ports(self) -> None:
self.update(path=URL_GET + GROUP.format(group=INPUT))
self.update(path=URL_GET + GROUP.format(group=IOPORT))
self.update(path=URL_GET + GROUP.format(group=OUTPUT))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_ports'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '26', '44']}; {'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']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '+'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'URL_GET'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'GROUP'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'INPUT'}; {'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': 'update'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '+'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'URL_GET'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'GROUP'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'IOPORT'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '+'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'URL_GET'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'GROUP'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'OUTPUT'}
|
Update port groups of parameters.
|
def run_selected_clicked(self):
rows = sorted(set(index.row() for index in
self.table.selectedIndexes()))
self.enable_busy_cursor()
for row in rows:
current_row = row
item = self.table.item(current_row, 0)
status_item = self.table.item(current_row, 1)
self.run_task(item, status_item)
self.disable_busy_cursor()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_selected_clicked'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '29', '35', '75']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '14', 'type': 'generator_expression', 'children': ['15', '20']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'index'}; {'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': 'table'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'selectedIndexes'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'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': 'enable_busy_cursor'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '38', 'type': 'block', 'children': ['39', '43', '55', '67']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'current_row'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '46', 'type': 'call', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'current_row'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'status_item'}; {'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': 'table'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'current_row'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'run_task'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'status_item'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'disable_busy_cursor'}; {'id': '80', 'type': 'argument_list', 'children': []}
|
Run the selected scenario.
|
def _get_extension_by_field(self, name):
if name is None:
raise TypeError("Expected field name")
tr_model = self.get_model_by_field(name)
for meta in self._extensions:
if meta.model == tr_model:
return meta
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_extension_by_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '26']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'raise_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"Expected field name"'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tr_model'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_model_by_field'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '31']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_extensions'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '38']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '37'], 'value': '=='}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'tr_model'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'meta'}
|
Find the ParlerOptions object that corresponds with the given translated field.
|
def calculate_extents(labels, indexes):
fix = fixup_scipy_ndimage_result
areas = fix(scind.sum(np.ones(labels.shape),labels,np.array(indexes, dtype=np.int32)))
y,x = np.mgrid[0:labels.shape[0],0:labels.shape[1]]
xmin = fix(scind.minimum(x, labels, indexes))
xmax = fix(scind.maximum(x, labels, indexes))
ymin = fix(scind.minimum(y, labels, indexes))
ymax = fix(scind.maximum(y, labels, indexes))
bbareas = (xmax-xmin+1)*(ymax-ymin+1)
return areas / bbareas
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_extents'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'indexes'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '42', '67', '81', '95', '109', '123', '139']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fix'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'fixup_scipy_ndimage_result'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'areas'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'fix'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'scind'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '30', '31']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ones'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'indexes'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'int32'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'pattern_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '47', 'type': 'subscript', 'children': ['48', '51', '59']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'mgrid'}; {'id': '51', 'type': 'slice', 'children': ['52', '53', '54']}; {'id': '52', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '53', 'type': 'colon', 'children': []}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'slice', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '61', 'type': 'colon', 'children': []}; {'id': '62', 'type': 'subscript', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'xmin'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'fix'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'scind'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'minimum'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79', '80']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'indexes'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'xmax'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'fix'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'scind'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'maximum'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93', '94']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'indexes'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'ymin'}; {'id': '98', 'type': 'call', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'fix'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'scind'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'minimum'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107', '108']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'indexes'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'ymax'}; {'id': '112', 'type': 'call', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'fix'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'scind'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'maximum'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '121', '122']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'indexes'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'bbareas'}; {'id': '126', 'type': 'binary_operator', 'children': ['127', '133'], 'value': '*'}; {'id': '127', 'type': '()', 'children': ['128']}; {'id': '128', 'type': 'binary_operator', 'children': ['129', '132'], 'value': '+'}; {'id': '129', 'type': 'binary_operator', 'children': ['130', '131'], 'value': '-'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'xmax'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'xmin'}; {'id': '132', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '133', 'type': '()', 'children': ['134']}; {'id': '134', 'type': 'binary_operator', 'children': ['135', '138'], 'value': '+'}; {'id': '135', 'type': 'binary_operator', 'children': ['136', '137'], 'value': '-'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'ymax'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'ymin'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '139', 'type': 'return_statement', 'children': ['140']}; {'id': '140', 'type': 'binary_operator', 'children': ['141', '142'], 'value': '/'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'areas'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'bbareas'}
|
Return the area of each object divided by the area of its bounding box
|
def prevPlot(self):
if self.stacker.currentIndex() > 0:
self.stacker.setCurrentIndex(self.stacker.currentIndex()-1)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prevPlot'}; {'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', '16']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '15'], 'value': '>'}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stacker'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'currentIndex'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'stacker'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'setCurrentIndex'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '33'], 'value': '-'}; {'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': 'stacker'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'currentIndex'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}
|
Moves the displayed plot to the previous one
|
def on_batch_end(self, last_target, train, **kwargs):
"Update the metrics if not `train`"
if train: return
bs = last_target.size(0)
for name in self.names:
self.metrics[name] += bs * self.learn.loss_func.metrics[name].detach().cpu()
self.nums += bs
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_batch_end'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'last_target'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'train'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '12', '16', '25', '57']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"Update the metrics if not `train`"'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'train'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'bs'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'last_target'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '30']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'augmented_assignment', 'children': ['33', '38'], 'value': '+='}; {'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': 'metrics'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '*'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'bs'}; {'id': '40', 'type': 'call', 'children': ['41', '56']}; {'id': '41', 'type': 'attribute', 'children': ['42', '55']}; {'id': '42', 'type': 'call', 'children': ['43', '54']}; {'id': '43', 'type': 'attribute', 'children': ['44', '53']}; {'id': '44', 'type': 'subscript', 'children': ['45', '52']}; {'id': '45', 'type': 'attribute', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'learn'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'loss_func'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'detach'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'cpu'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'augmented_assignment', 'children': ['59', '62'], 'value': '+='}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'nums'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'bs'}
|
Update the metrics if not `train`
|
def render_to_string(self, template_file, context):
context = context if context else {}
if self.object:
context['object'] = self.object
context[self.object.__class__.__name__.lower()] = self.object
return render_to_string(template_file, context, self.request)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_to_string'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'template_file'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '46']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '11', 'type': 'conditional_expression', 'children': ['12', '13', '14'], 'value': 'if'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '14', 'type': 'dictionary', 'children': []}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '19', 'type': 'block', 'children': ['20', '28']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'object'"}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '43']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '32', 'type': 'call', 'children': ['33', '42']}; {'id': '33', 'type': 'attribute', 'children': ['34', '41']}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'render_to_string'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51', '52']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'template_file'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'request'}
|
Render given template to string and add object to context
|
def param_apropos(self, args):
if len(args) == 0:
print("Usage: param apropos keyword")
return
htree = self.param_help_tree()
if htree is None:
return
contains = {}
for keyword in args:
for param in htree.keys():
if str(htree[param]).find(keyword) != -1:
contains[param] = True
for param in contains.keys():
print("%s" % (param,))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'param_apropos'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '29', '35', '39', '73']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '=='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'block', 'children': ['15', '20']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"Usage: param apropos keyword"'}; {'id': '20', 'type': 'return_statement', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'htree'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'param_help_tree'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'if_statement', 'children': ['30', '33']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'is'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'htree'}; {'id': '32', 'type': 'None', 'children': []}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'contains'}; {'id': '38', 'type': 'dictionary', 'children': []}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'keyword'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'for_statement', 'children': ['44', '45', '50']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'htree'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'if_statement', 'children': ['52', '66']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '64'], 'value': '!='}; {'id': '53', 'type': 'call', 'children': ['54', '62']}; {'id': '54', 'type': 'attribute', 'children': ['55', '61']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'htree'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'keyword'}; {'id': '64', 'type': 'unary_operator', 'children': ['65'], 'value': '-'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '72']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'contains'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '72', 'type': 'True', 'children': []}; {'id': '73', 'type': 'for_statement', 'children': ['74', '75', '80']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'contains'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '79', 'type': 'argument_list', 'children': []}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '%'}; {'id': '86', 'type': 'string', 'children': [], 'value': '"%s"'}; {'id': '87', 'type': 'tuple', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'param'}
|
search parameter help for a keyword, list those parameters
|
def _write(self, session, openFile, replaceParamFile):
timeSeries = self.timeSeries
numTS = len(timeSeries)
valList = []
for tsNum, ts in enumerate(timeSeries):
values = ts.values
for value in values:
valDict = {'time': value.simTime,
'tsNum': tsNum,
'value': value.value}
valList.append(valDict)
result = pivot(valList, ('time',), ('tsNum',), 'value')
for line in result:
valString = ''
for n in range(0, numTS):
val = '%.6f' % line[(n,)]
valString = '%s%s%s' % (
valString,
' ' * (13 - len(str(val))),
val)
openFile.write(' %.8f%s\n' % (line['time'], valString))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'openFile'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'replaceParamFile'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '22', '26', '69', '81']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'timeSeries'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'timeSeries'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'numTS'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'timeSeries'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'valList'}; {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '30', '34']}; {'id': '27', 'type': 'pattern_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'tsNum'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ts'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'timeSeries'}; {'id': '34', 'type': 'block', 'children': ['35', '41']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ts'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '41', 'type': 'for_statement', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '44', 'type': 'block', 'children': ['45', '62']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'valDict'}; {'id': '48', 'type': 'dictionary', 'children': ['49', '54', '57']}; {'id': '49', 'type': 'pair', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'time'"}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'simTime'}; {'id': '54', 'type': 'pair', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'tsNum'"}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'tsNum'}; {'id': '57', 'type': 'pair', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'valList'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'valDict'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'pivot'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76', '78', '80']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'valList'}; {'id': '76', 'type': 'tuple', 'children': ['77']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'time'"}; {'id': '78', 'type': 'tuple', 'children': ['79']}; {'id': '79', 'type': 'string', 'children': [], 'value': "'tsNum'"}; {'id': '80', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '81', 'type': 'for_statement', 'children': ['82', '83', '84']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '84', 'type': 'block', 'children': ['85', '89', '126']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'valString'}; {'id': '88', 'type': 'string', 'children': [], 'value': "''"}; {'id': '89', 'type': 'for_statement', 'children': ['90', '91', '96']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95']}; {'id': '94', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'numTS'}; {'id': '96', 'type': 'block', 'children': ['97', '106']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '%'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'%.6f'"}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '104', 'type': 'tuple', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'valString'}; {'id': '109', 'type': 'binary_operator', 'children': ['110', '111'], 'value': '%'}; {'id': '110', 'type': 'string', 'children': [], 'value': "'%s%s%s'"}; {'id': '111', 'type': 'tuple', 'children': ['112', '113', '125']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'valString'}; {'id': '113', 'type': 'binary_operator', 'children': ['114', '115'], 'value': '*'}; {'id': '114', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '115', 'type': '()', 'children': ['116']}; {'id': '116', 'type': 'binary_operator', 'children': ['117', '118'], 'value': '-'}; {'id': '117', 'type': 'integer', 'children': [], 'value': '13'}; {'id': '118', 'type': 'call', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'openFile'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'binary_operator', 'children': ['133', '134'], 'value': '%'}; {'id': '133', 'type': 'string', 'children': [], 'value': "' %.8f%s\\n'"}; {'id': '134', 'type': 'tuple', 'children': ['135', '138']}; {'id': '135', 'type': 'subscript', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '137', 'type': 'string', 'children': [], 'value': "'time'"}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'valString'}
|
Generic Time Series Write to File Method
|
async def destroy_unit(self, *unit_names):
connection = self.connection()
app_facade = client.ApplicationFacade.from_connection(connection)
log.debug(
'Destroying unit%s %s',
's' if len(unit_names) == 1 else '',
' '.join(unit_names))
return await app_facade.DestroyUnits(list(unit_names))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'destroy_unit'}; {'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': 'unit_names'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '27', '49']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'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': 'connection'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'app_facade'}; {'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': 'client'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ApplicationFacade'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'from_connection'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'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': 'log'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '43']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'Destroying unit%s %s'"}; {'id': '34', 'type': 'conditional_expression', 'children': ['35', '36', '42'], 'value': 'if'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'s'"}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '41'], 'value': '=='}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'unit_names'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'string', 'children': [], 'value': "''"}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'unit_names'}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'await', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'app_facade'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'DestroyUnits'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'unit_names'}
|
Destroy units by name.
|
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if self.url:
iframe_html = '<iframe src="{}" frameborder="0" title="{}" allowfullscreen></iframe>'
self.html = iframe_html.format(
self.get_embed_url(),
self.title
)
return super().save(force_insert, force_update, using, update_fields)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'force_insert'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'force_update'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'update_fields'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '45']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '22', 'type': 'block', 'children': ['23', '27']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'iframe_html'}; {'id': '26', 'type': 'string', 'children': [], 'value': '\'<iframe src="{}" frameborder="0" title="{}" allowfullscreen></iframe>\''}; {'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': 'html'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'iframe_html'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '42']}; {'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': 'get_embed_url'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54', '55', '56']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'force_insert'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'force_update'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'update_fields'}
|
Set html field with correct iframe.
|
def generate_docker_compose(self):
example = {}
example['app'] = {}
example['app']['environment'] = []
for key in sorted(list(self.spec.keys())):
if self.spec[key]['type'] in (dict, list):
value = f"\'{json.dumps(self.spec[key].get('example', ''))}\'"
else:
value = f"{self.spec[key].get('example', '')}"
example['app']['environment'].append(f"{self.env_prefix}_{key.upper()}={value}")
print(yaml.dump(example, default_flow_style=False))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_docker_compose'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '16', '24', '74']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '15']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'app'"}; {'id': '15', 'type': 'dictionary', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'app'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'environment'"}; {'id': '23', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '39']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '31', 'type': 'argument_list', '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': 'spec'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40', '63']}; {'id': '40', 'type': 'if_statement', 'children': ['41', '52', '57']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '49'], 'value': 'in'}; {'id': '42', 'type': 'subscript', 'children': ['43', '48']}; {'id': '43', 'type': 'subscript', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '49', 'type': 'tuple', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'list'}; {'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': 'value'}; {'id': '56', 'type': 'string', 'children': [], 'value': 'f"\\\'{json.dumps(self.spec[key].get(\'example\', \'\'))}\\\'"'}; {'id': '57', 'type': 'else_clause', 'children': ['58']}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '62', 'type': 'string', 'children': [], 'value': 'f"{self.spec[key].get(\'example\', \'\')}"'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '72']}; {'id': '65', 'type': 'attribute', 'children': ['66', '71']}; {'id': '66', 'type': 'subscript', 'children': ['67', '70']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'app'"}; {'id': '70', 'type': 'string', 'children': [], 'value': "'environment'"}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': 'f"{self.env_prefix}_{key.upper()}={value}"'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'default_flow_style'}; {'id': '86', 'type': 'False', 'children': []}
|
Generate a sample docker compose
|
def stop(self) -> None:
if self._stop and not self._posted_kork:
self._stop()
self._stop = None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '17']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '13'], 'value': 'and'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_stop'}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_posted_kork'}; {'id': '17', 'type': 'block', 'children': ['18', '24']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_stop'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_stop'}; {'id': '29', 'type': 'None', 'children': []}
|
Stops the analysis as soon as possible.
|
def estimate_max_mapq(in_bam, nreads=1e6):
with pysam.Samfile(in_bam, "rb") as work_bam:
reads = tz.take(int(nreads), work_bam)
return max([x.mapq for x in reads if not x.is_unmapped])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'estimate_max_mapq'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'in_bam'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'nreads'}; {'id': '7', 'type': 'float', 'children': [], 'value': '1e6'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'with_statement', 'children': ['10', '22']}; {'id': '10', 'type': 'with_clause', 'children': ['11']}; {'id': '11', 'type': 'with_item', 'children': ['12']}; {'id': '12', 'type': 'as_pattern', 'children': ['13', '20']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pysam'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Samfile'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'in_bam'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"rb"'}; {'id': '20', 'type': 'as_pattern_target', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'work_bam'}; {'id': '22', 'type': 'block', 'children': ['23', '36']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'reads'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'take'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '35']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'nreads'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'work_bam'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'list_comprehension', 'children': ['41', '44', '47']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'mapq'}; {'id': '44', 'type': 'for_in_clause', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'reads'}; {'id': '47', 'type': 'if_clause', 'children': ['48']}; {'id': '48', 'type': 'not_operator', 'children': ['49']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'is_unmapped'}
|
Guess maximum MAPQ in a BAM file of reads with alignments
|
def compute_distances_dict(egg):
pres, rec, features, dist_funcs = parse_egg(egg)
pres_list = list(pres)
features_list = list(features)
distances = {}
for idx1, item1 in enumerate(pres_list):
distances[item1]={}
for idx2, item2 in enumerate(pres_list):
distances[item1][item2]={}
for feature in dist_funcs:
distances[item1][item2][feature] = builtin_dist_funcs[dist_funcs[feature]](features_list[idx1][feature],features_list[idx2][feature])
return distances
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_distances_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'egg'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '24', '31', '35', '97']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '13']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10', '11', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pres'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'features'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dist_funcs'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parse_egg'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'egg'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pres_list'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pres'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'features_list'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'features'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '34', 'type': 'dictionary', 'children': []}; {'id': '35', 'type': 'for_statement', 'children': ['36', '39', '43']}; {'id': '36', 'type': 'pattern_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'idx1'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'item1'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pres_list'}; {'id': '43', 'type': 'block', 'children': ['44', '50']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'item1'}; {'id': '49', 'type': 'dictionary', 'children': []}; {'id': '50', 'type': 'for_statement', 'children': ['51', '54', '58']}; {'id': '51', 'type': 'pattern_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'idx2'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'item2'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'pres_list'}; {'id': '58', 'type': 'block', 'children': ['59', '67']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '66']}; {'id': '61', 'type': 'subscript', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'item1'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'item2'}; {'id': '66', 'type': 'dictionary', 'children': []}; {'id': '67', 'type': 'for_statement', 'children': ['68', '69', '70']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'dist_funcs'}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '80']}; {'id': '73', 'type': 'subscript', 'children': ['74', '79']}; {'id': '74', 'type': 'subscript', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'item1'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'item2'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '80', 'type': 'call', 'children': ['81', '86']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'builtin_dist_funcs'}; {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'dist_funcs'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '92']}; {'id': '87', 'type': 'subscript', 'children': ['88', '91']}; {'id': '88', 'type': 'subscript', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'features_list'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'idx1'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '92', 'type': 'subscript', 'children': ['93', '96']}; {'id': '93', 'type': 'subscript', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'features_list'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'idx2'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'distances'}
|
Creates a nested dict of distances
|
def write(self, frame):
if not isinstance(frame, FrameBase):
raise PyVLXException("Frame not of type FrameBase", frame_type=type(frame))
PYVLXLOG.debug("SEND: %s", frame)
self.transport.write(slip_pack(bytes(frame)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '6', 'type': 'block', 'children': ['7', '26', '34']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'FrameBase'}; {'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': 'PyVLXException'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"Frame not of type FrameBase"'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'frame_type'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'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': 'PYVLXLOG'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"SEND: %s"'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'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': 'transport'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'slip_pack'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'frame'}
|
Write frame to Bus.
|
def load_lists(keys=[], values=[], name='NT'):
mapping = dict(zip(keys, values))
return mapper(mapping, _nt_name=name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_lists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '6', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'NT'"}; {'id': '13', 'type': 'block', 'children': ['14', '25']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'mapper'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_nt_name'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Map namedtuples given a pair of key, value lists.
|
def radlToSimple(radl_data):
aspects = (radl_data.ansible_hosts + radl_data.networks + radl_data.systems +
radl_data.configures + radl_data.deploys)
if radl_data.contextualize.items is not None:
aspects.append(radl_data.contextualize)
return [aspectToSimple(a) for a in aspects]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'radlToSimple'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '5', 'type': 'block', 'children': ['6', '29', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'aspects'}; {'id': '9', 'type': '()', 'children': ['10']}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '26'], 'value': '+'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '23'], 'value': '+'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '20'], 'value': '+'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '17'], 'value': '+'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ansible_hosts'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'networks'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'systems'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'configures'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'deploys'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '37']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '36'], 'value': 'is not'}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'contextualize'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'aspects'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'radl_data'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'contextualize'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'list_comprehension', 'children': ['49', '53']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'aspectToSimple'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '53', 'type': 'for_in_clause', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'aspects'}
|
Return a list of maps whose values are only other maps or lists.
|
def pass_community(f):
@wraps(f)
def inner(community_id, *args, **kwargs):
c = Community.get(community_id)
if c is None:
abort(404)
return f(c, *args, **kwargs)
return inner
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pass_community'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '5', 'type': 'block', 'children': ['6', '49']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '12']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '12', 'type': 'function_definition', 'children': ['13', '14', '20']}; {'id': '13', 'type': 'function_name', 'children': [], 'value': 'inner'}; {'id': '14', 'type': 'parameters', 'children': ['15', '16', '18']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'community_id'}; {'id': '16', 'type': 'list_splat_pattern', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '18', 'type': 'dictionary_splat_pattern', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '20', 'type': 'block', 'children': ['21', '30', '40']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Community'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'community_id'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '34']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': 'is'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'abort'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'integer', 'children': [], 'value': '404'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45', '47']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '45', 'type': 'list_splat', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '47', 'type': 'dictionary_splat', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'inner'}
|
Decorator to pass community.
|
def preview_filter_from_query(query, id_field="id", field_map={}):
f = groups_filter_from_query(query, field_map=field_map)
included_ids = query.get("included_ids")
if included_ids:
if f:
f |= Terms(pk=included_ids)
else:
f = Terms(pk=included_ids)
return f
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'preview_filter_from_query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'id_field'}; {'id': '7', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'field_map'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '22', '31', '57']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'groups_filter_from_query'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'field_map'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'field_map'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'included_ids'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"included_ids"'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'included_ids'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'if_statement', 'children': ['35', '36', '46']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'augmented_assignment', 'children': ['39', '40'], 'value': '|='}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Terms'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'included_ids'}; {'id': '46', 'type': 'else_clause', 'children': ['47']}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'Terms'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'included_ids'}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'f'}
|
This filter includes the "excluded_ids" so they still show up in the editor.
|
def get(self, nb=0):
return {i: self.stats_history[i].history_raw(nb=nb) for i in self.stats_history}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'dictionary_comprehension', 'children': ['11', '25']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '13', 'type': 'call', 'children': ['14', '21']}; {'id': '14', 'type': 'attribute', 'children': ['15', '20']}; {'id': '15', 'type': 'subscript', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'stats_history'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'history_raw'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'stats_history'}
|
Get the history as a dict of list
|
def atlas_peer_is_whitelisted( peer_hostport, peer_table=None ):
ret = None
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return None
ret = ptbl[peer_hostport].get("whitelisted", False)
return ret
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'atlas_peer_is_whitelisted'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'peer_hostport'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'peer_table'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '13', '47']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'with_statement', 'children': ['14', '23']}; {'id': '14', 'type': 'with_clause', 'children': ['15']}; {'id': '15', 'type': 'with_item', 'children': ['16']}; {'id': '16', 'type': 'as_pattern', 'children': ['17', '21']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'AtlasPeerTableLocked'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'peer_table'}; {'id': '21', 'type': 'as_pattern_target', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ptbl'}; {'id': '23', 'type': 'block', 'children': ['24', '35']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '32']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'not in'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'peer_hostport'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ptbl'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ptbl'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'peer_hostport'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': '"whitelisted"'}; {'id': '46', 'type': 'False', 'children': []}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ret'}
|
Is a peer whitelisted
|
def graft(coll, branch, index):
pre = coll[:index]
post = coll[index:]
ret = pre + branch + post
return ret
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'graft'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'coll'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'branch'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '24', '32']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'pre'}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'coll'}; {'id': '13', 'type': 'slice', 'children': ['14', '15']}; {'id': '14', 'type': 'colon', 'children': []}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'coll'}; {'id': '21', 'type': 'slice', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '23', 'type': 'colon', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '31'], 'value': '+'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '+'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pre'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'branch'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ret'}
|
Graft list branch into coll at index
|
def color(self):
color = idc.GetColor(self.ea, idc.CIC_ITEM)
if color == 0xFFFFFFFF:
return None
return color
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'color'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '27']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'idc'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'GetColor'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ea'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'idc'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'CIC_ITEM'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': '=='}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0xFFFFFFFF'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'color'}
|
Line color in IDA View
|
def _convert_point(cls, feature):
lon, lat = feature['geometry']['coordinates']
popup = feature['properties'].get('name', '')
return cls(lat, lon)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_point'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '29']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'subscript', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'geometry'"}; {'id': '16', 'type': 'string', 'children': [], 'value': "'coordinates'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'popup'}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'properties'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "''"}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'lon'}
|
Convert a GeoJSON point to a Marker.
|
def reconstruct(self, t:Tensor, x:Tensor=None):
"Reconstruct one of the underlying item for its data `t`."
return self[0].reconstruct(t,x) if has_arg(self[0].reconstruct, 'x') else self[0].reconstruct(t)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reconstruct'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Tensor'}; {'id': '9', 'type': 'typed_default_parameter', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Tensor'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '17']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"Reconstruct one of the underlying item for its data `t`."'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'conditional_expression', 'children': ['19', '28', '37'], 'value': 'if'}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'reconstruct'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'has_arg'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'reconstruct'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'x'"}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'reconstruct'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 't'}
|
Reconstruct one of the underlying item for its data `t`.
|
def geojson(self, feature_id):
if self._geojson.get('id', feature_id) == feature_id:
return self._geojson
else:
geo = self._geojson.copy()
geo['id'] = feature_id
return geo
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'geojson'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'feature_id'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '19', '24']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '18'], 'value': '=='}; {'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': '_geojson'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'feature_id'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'feature_id'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_geojson'}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26', '36', '42']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'geo'}; {'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': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_geojson'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'geo'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'feature_id'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'geo'}
|
Return GeoJSON with ID substituted.
|
def invoked(self, ctx):
if not ctx.ansi.is_enabled:
print("You need color support to use this demo")
else:
print(ctx.ansi.cmd('erase_display'))
self._demo_fg_color(ctx)
self._demo_bg_color(ctx)
self._demo_bg_indexed(ctx)
self._demo_rgb(ctx)
self._demo_style(ctx)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'invoked'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14', '20']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ansi'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'is_enabled'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"You need color support to use this demo"'}; {'id': '20', 'type': 'else_clause', 'children': ['21']}; {'id': '21', 'type': 'block', 'children': ['22', '34', '41', '48', '55', '62']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '25', 'type': 'argument_list', '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': 'ctx'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ansi'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'erase_display'"}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_demo_fg_color'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'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': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_demo_bg_color'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'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': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_demo_bg_indexed'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_demo_rgb'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_demo_style'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ctx'}
|
Method called when the command is invoked.
|
def remove(self, experiment):
try:
project_path = self.projects[self[experiment]['project']]['root']
except KeyError:
return
config_path = osp.join(project_path, '.project', experiment + '.yml')
for f in [config_path, config_path + '~', config_path + '.lck']:
if os.path.exists(f):
os.remove(f)
del self[experiment]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'experiment'}; {'id': '6', 'type': 'block', 'children': ['7', '27', '40', '68']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '23']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'project_path'}; {'id': '12', 'type': 'subscript', 'children': ['13', '22']}; {'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': 'projects'}; {'id': '17', 'type': 'subscript', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'experiment'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'project'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'root'"}; {'id': '23', 'type': 'except_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'config_path'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'osp'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'project_path'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'.project'"}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '+'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'experiment'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'.yml'"}; {'id': '40', 'type': 'for_statement', 'children': ['41', '42', '50']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '42', 'type': 'list', 'children': ['43', '44', '47'], 'value': "[config_path, config_path + '~', config_path + '.lck']"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'config_path'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '+'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'config_path'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'~'"}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '49'], 'value': '+'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'config_path'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'.lck'"}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'if_statement', 'children': ['52', '60']}; {'id': '52', 'type': 'call', 'children': ['53', '58']}; {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '68', 'type': 'delete_statement', 'children': ['69']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'experiment'}
|
Remove the configuration of an experiment
|
def run(self, graminit_h, graminit_c):
self.parse_graminit_h(graminit_h)
self.parse_graminit_c(graminit_c)
self.finish_off()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'graminit_h'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'graminit_c'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '22']}; {'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': 'parse_graminit_h'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'graminit_h'}; {'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': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'parse_graminit_c'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'graminit_c'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'finish_off'}; {'id': '27', 'type': 'argument_list', 'children': []}
|
Load the grammar tables from the text files written by pgen.
|
def create_migration_ctx(**kwargs):
env = EnvironmentContext(Config(), None)
env.configure(
connection=db.engine.connect(),
sqlalchemy_module_prefix='db.',
**kwargs
)
return env.get_context()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_migration_ctx'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'dictionary_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '37']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'EnvironmentContext'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Config'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'None', 'children': []}; {'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': 'env'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'configure'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '32', '35']}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'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': 'db'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sqlalchemy_module_prefix'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'db.'"}; {'id': '35', 'type': 'dictionary_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get_context'}; {'id': '42', 'type': 'argument_list', 'children': []}
|
Create an alembic migration context.
|
def keep_only_current_window(self):
self.tab_pages = [TabPage(self.active_tab.active_window)]
self.active_tab_index = 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'keep_only_current_window'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20']}; {'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': 'tab_pages'}; {'id': '11', 'type': 'list', 'children': ['12'], 'value': '[TabPage(self.active_tab.active_window)]'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'TabPage'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'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': 'active_tab'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'active_window'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'active_tab_index'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}
|
Close all other windows, except the current one.
|
def keyPressEvent(self, event):
ctrl = event.modifiers() & Qt.ControlModifier
shift = event.modifiers() & Qt.ShiftModifier
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
self.find.emit()
elif event.key() == Qt.Key_F and ctrl and shift:
self.parent().toggle_visibility.emit(not self.isVisible())
else:
QWidget.keyPressEvent(self, event)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'keyPressEvent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '31']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ctrl'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '16'], 'value': '&'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'modifiers'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ControlModifier'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'shift'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '28'], 'value': '&'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'modifiers'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ShiftModifier'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '45', '54', '87']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '38'], 'value': 'in'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'tuple', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Key_Enter'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'Key_Return'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '53']}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'emit'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'elif_clause', 'children': ['55', '68']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '67'], 'value': 'and'}; {'id': '56', 'type': 'boolean_operator', 'children': ['57', '66'], 'value': 'and'}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '63'], 'value': '=='}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'Key_F'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'ctrl'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'shift'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '80']}; {'id': '71', 'type': 'attribute', 'children': ['72', '79']}; {'id': '72', 'type': 'attribute', 'children': ['73', '78']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'toggle_visibility'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'emit'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'not_operator', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'isVisible'}; {'id': '86', 'type': 'argument_list', 'children': []}; {'id': '87', 'type': 'else_clause', 'children': ['88']}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'QWidget'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'keyPressEvent'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'event'}
|
Reimplemented to handle key events
|
def _notify_thing_lid_change(self, from_lid, to_lid):
try:
with self.__private_things:
self.__private_things[to_lid] = self.__private_things.pop(from_lid)
except KeyError:
logger.warning('Thing %s renamed (to %s), but not in private lookup table', from_lid, to_lid)
else:
try:
with self.__new_things:
self.__new_things[to_lid] = self.__new_things.pop(from_lid)
except KeyError:
pass
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_notify_thing_lid_change'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'from_lid'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'to_lid'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '32', '44']}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'with_statement', 'children': ['11', '16']}; {'id': '11', 'type': 'with_clause', 'children': ['12']}; {'id': '12', 'type': 'with_item', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '__private_things'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '24']}; {'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': '__private_things'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'to_lid'}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '__private_things'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'from_lid'}; {'id': '32', 'type': 'except_clause', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42', '43']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'Thing %s renamed (to %s), but not in private lookup table'"}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'from_lid'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'to_lid'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'try_statement', 'children': ['47', '70']}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'with_statement', 'children': ['49', '54']}; {'id': '49', 'type': 'with_clause', 'children': ['50']}; {'id': '50', 'type': 'with_item', 'children': ['51']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '__new_things'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '62']}; {'id': '57', 'type': 'subscript', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '__new_things'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'to_lid'}; {'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': '__new_things'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'from_lid'}; {'id': '70', 'type': 'except_clause', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'pass_statement', 'children': []}
|
Used by Thing instances to indicate that a rename operation has happened
|
def from_json(cls, json_info):
if json_info is None:
return None
return TrialRecord(
trial_id=json_info["trial_id"],
job_id=json_info["job_id"],
trial_status=json_info["status"],
start_time=json_info["start_time"],
params=json_info["params"])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'json_info'}; {'id': '6', 'type': 'block', 'children': ['7', '14']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'json_info'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'TrialRecord'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '23', '28', '33', '38']}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'trial_id'}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'json_info'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"trial_id"'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'job_id'}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'json_info'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"job_id"'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'trial_status'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'json_info'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"status"'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'json_info'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"start_time"'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'json_info'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"params"'}
|
Build a Trial instance from a json string.
|
def interpolate(text, global_dict=None, local_dict=None):
try:
return eval(as_fstring(text), global_dict, local_dict)
except Exception as e:
raise ValueError(f'Failed to interpolate {text}: {e}')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interpolate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'global_dict'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'local_dict'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'try_statement', 'children': ['13', '24']}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'eval'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '22', '23']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'as_fstring'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'global_dict'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'local_dict'}; {'id': '24', 'type': 'except_clause', 'children': ['25', '29']}; {'id': '25', 'type': 'as_pattern', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '27', 'type': 'as_pattern_target', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'raise_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "f'Failed to interpolate {text}: {e}'"}
|
Evaluate expressions in `text`
|
def run_reducer(self, stdin=sys.stdin, stdout=sys.stdout):
self.init_hadoop()
self.init_reducer()
outputs = self._reduce_input(self.internal_reader((line[:-1] for line in stdin)), self.reducer, self.final_reducer)
self.writer(outputs, stdout)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_reducer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '15', 'type': 'block', 'children': ['16', '22', '28', '57']}; {'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': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'init_hadoop'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'init_reducer'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_reduce_input'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '51', '54']}; {'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': 'internal_reader'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'generator_expression', 'children': ['42', '48']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'line'}; {'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': '1'}; {'id': '48', 'type': 'for_in_clause', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'reducer'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'final_reducer'}; {'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': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'writer'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'stdout'}
|
Run the reducer on the hadoop node.
|
def print_version(ctx, value):
if not value:
return
import pkg_resources
version = None
try:
version = pkg_resources.get_distribution('sandman').version
finally:
del pkg_resources
click.echo(version)
ctx.exit()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7', '12', '15', '19', '36', '43']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '10']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': []}; {'id': '12', 'type': 'import_statement', 'children': ['13']}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'try_statement', 'children': ['20', '32']}; {'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': 'version'}; {'id': '24', 'type': 'attribute', 'children': ['25', '31']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'get_distribution'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'sandman'"}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '32', 'type': 'finally_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'delete_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'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': 'click'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'version'}; {'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': 'ctx'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '48', 'type': 'argument_list', 'children': []}
|
Print the current version of sandman and exit.
|
def validate_uses_tls_for_glance(audit_options):
section = _config_section(audit_options, 'glance')
assert section is not None, "Missing section 'glance'"
assert not section.get('insecure') and \
"https://" in section.get("api_servers"), \
"TLS is not used for Glance"
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_uses_tls_for_glance'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'audit_options'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '19']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_config_section'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'audit_options'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'glance'"}; {'id': '14', 'type': 'assert_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': 'is not'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Missing section \'glance\'"'}; {'id': '19', 'type': 'assert_statement', 'children': ['20', '36']}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '28'], 'value': 'and'}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'insecure'"}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': 'in'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"https://"'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"api_servers"'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"TLS is not used for Glance"'}
|
Verify that TLS is used to communicate with Glance.
|
def _server_loop(self, client, client_addr):
while not self._stopped and not _shutting_down:
try:
with self._unlock():
request = mock_server_receive_request(client, self)
self._requests_count += 1
self._log('%d\t%r' % (request.client_port, request))
for responder in reversed(self._autoresponders):
if responder.handle(request):
self._log('\t(autoresponse)')
break
else:
self._request_q.put(request)
except socket.error as error:
if error.errno in (errno.ECONNRESET, errno.EBADF):
break
raise
except select.error as error:
if error.args[0] == errno.EBADF:
break
else:
raise
except AssertionError:
traceback.print_exc()
break
self._log('disconnected: %s' % format_addr(client_addr))
client.close()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_server_loop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'client_addr'}; {'id': '7', 'type': 'block', 'children': ['8', '147', '159']}; {'id': '8', 'type': 'while_statement', 'children': ['9', '16']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '14'], 'value': 'and'}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_stopped'}; {'id': '14', 'type': 'not_operator', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_shutting_down'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'try_statement', 'children': ['18', '91', '114', '137']}; {'id': '18', 'type': 'block', 'children': ['19', '36', '42', '55']}; {'id': '19', 'type': 'with_statement', 'children': ['20', '27']}; {'id': '20', 'type': 'with_clause', 'children': ['21']}; {'id': '21', 'type': 'with_item', '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': '_unlock'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'mock_server_receive_request'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'augmented_assignment', 'children': ['38', '41'], 'value': '+='}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_requests_count'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '%'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'%d\\t%r'"}; {'id': '50', 'type': 'tuple', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'client_port'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '55', 'type': 'for_statement', 'children': ['56', '57', '63', '80']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'responder'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_autoresponders'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'if_statement', 'children': ['65', '71']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'responder'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '71', 'type': 'block', 'children': ['72', '79']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'\\t(autoresponse)'"}; {'id': '79', 'type': 'break_statement', 'children': []}; {'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', '89']}; {'id': '84', 'type': 'attribute', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': '_request_q'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '91', 'type': 'except_clause', 'children': ['92', '98']}; {'id': '92', 'type': 'as_pattern', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '96', 'type': 'as_pattern_target', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '98', 'type': 'block', 'children': ['99', '113']}; {'id': '99', 'type': 'if_statement', 'children': ['100', '111']}; {'id': '100', 'type': 'comparison_operator', 'children': ['101', '104'], 'value': 'in'}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '104', 'type': 'tuple', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'ECONNRESET'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'EBADF'}; {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'break_statement', 'children': []}; {'id': '113', 'type': 'raise_statement', 'children': []}; {'id': '114', 'type': 'except_clause', 'children': ['115', '121']}; {'id': '115', 'type': 'as_pattern', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '119', 'type': 'as_pattern_target', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'if_statement', 'children': ['123', '132', '134']}; {'id': '123', 'type': 'comparison_operator', 'children': ['124', '129'], 'value': '=='}; {'id': '124', 'type': 'subscript', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '128', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'EBADF'}; {'id': '132', 'type': 'block', 'children': ['133']}; {'id': '133', 'type': 'break_statement', 'children': []}; {'id': '134', 'type': 'else_clause', 'children': ['135']}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'raise_statement', 'children': []}; {'id': '137', 'type': 'except_clause', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'AssertionError'}; {'id': '139', 'type': 'block', 'children': ['140', '146']}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'print_exc'}; {'id': '145', 'type': 'argument_list', 'children': []}; {'id': '146', 'type': 'break_statement', 'children': []}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}; {'id': '153', 'type': 'binary_operator', 'children': ['154', '155'], 'value': '%'}; {'id': '154', 'type': 'string', 'children': [], 'value': "'disconnected: %s'"}; {'id': '155', 'type': 'call', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'format_addr'}; {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'client_addr'}; {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'call', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '164', 'type': 'argument_list', 'children': []}
|
Read requests from one client socket, 'client'.
|
def clear(self):
if os.path.exists(self.path):
os.remove(self.path)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'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', '17']}; {'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': 'os'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'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': 'path'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}
|
Remove all existing done markers and the file used to store the dones.
|
def _set_relative_pythonpath(self, value):
self.pythonpath = [osp.abspath(osp.join(self.root_path, path))
for path in value]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_relative_pythonpath'}; {'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': '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': 'pythonpath'}; {'id': '12', 'type': 'list_comprehension', 'children': ['13', '27']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'osp'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'osp'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'join'}; {'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': 'root_path'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'for_in_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Set PYTHONPATH list relative paths
|
def reverse_name_server(self, query, limit=None, **kwargs):
return self._results('reverse-name-server', '/v1/{0}/name-server-domains'.format(query),
items_path=('primary_domains', ), limit=limit, **kwargs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reverse_name_server'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'dictionary_splat_pattern', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_results'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '25', '29', '32']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'reverse-name-server'"}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'/v1/{0}/name-server-domains'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'items_path'}; {'id': '27', 'type': 'tuple', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'primary_domains'"}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '32', 'type': 'dictionary_splat', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Pass in a domain name or a name server.
|
def lpop(self, key, *, encoding=_NOTSET):
return self.execute(b'LPOP', key, encoding=encoding)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lpop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'keyword_separator', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_NOTSET'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_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': 'execute'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'string', 'children': [], 'value': "b'LPOP'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'encoding'}
|
Removes and returns the first element of the list stored at key.
|
def zipline_magic(line, cell=None):
load_extensions(
default=True,
extensions=[],
strict=True,
environ=os.environ,
)
try:
return run.main(
[
'--algotext', cell,
'--output', os.devnull,
] + ([
'--algotext', '',
'--local-namespace',
] if cell is None else []) + line.split(),
'%s%%zipline' % ((cell or '') and '%'),
standalone_mode=False,
)
except SystemExit as e:
if e.code:
raise ValueError('main returned non-zero status code: %d' % e.code)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zipline_magic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '27']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'load_extensions'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16', '19', '22']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '15', 'type': 'True', 'children': []}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'extensions'}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'strict'}; {'id': '21', 'type': 'True', 'children': []}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '27', 'type': 'try_statement', 'children': ['28', '71']}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '59', '68']}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '54'], 'value': '+'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '44'], 'value': '+'}; {'id': '37', 'type': 'list', 'children': ['38', '39', '40', '41'], 'value': "[\n '--algotext', cell,\n '--output', os.devnull,\n ]"}; {'id': '38', 'type': 'string', 'children': [], 'value': "'--algotext'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'--output'"}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'devnull'}; {'id': '44', 'type': '()', 'children': ['45']}; {'id': '45', 'type': 'conditional_expression', 'children': ['46', '50', '53'], 'value': 'if'}; {'id': '46', 'type': 'list', 'children': ['47', '48', '49'], 'value': "[\n '--algotext', '',\n '--local-namespace',\n ]"}; {'id': '47', 'type': 'string', 'children': [], 'value': "'--algotext'"}; {'id': '48', 'type': 'string', 'children': [], 'value': "''"}; {'id': '49', 'type': 'string', 'children': [], 'value': "'--local-namespace'"}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': 'is'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '%'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'%s%%zipline'"}; {'id': '61', 'type': '()', 'children': ['62']}; {'id': '62', 'type': 'boolean_operator', 'children': ['63', '67'], 'value': 'and'}; {'id': '63', 'type': '()', 'children': ['64']}; {'id': '64', 'type': 'boolean_operator', 'children': ['65', '66'], 'value': 'or'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '66', 'type': 'string', 'children': [], 'value': "''"}; {'id': '67', 'type': 'string', 'children': [], 'value': "'%'"}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'standalone_mode'}; {'id': '70', 'type': 'False', 'children': []}; {'id': '71', 'type': 'except_clause', 'children': ['72', '76']}; {'id': '72', 'type': 'as_pattern', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'SystemExit'}; {'id': '74', 'type': 'as_pattern_target', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'if_statement', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'raise_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'binary_operator', 'children': ['87', '88'], 'value': '%'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'main returned non-zero status code: %d'"}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'code'}
|
The zipline IPython cell magic.
|
def _stopLeader(cls):
with cls.lock:
assert cls.initialized > 0
cls.initialized -= 1
if cls.initialized == 0:
if cls.loggingServer:
log.info('Stopping real-time logging server.')
cls.loggingServer.shutdown()
cls.loggingServer = None
if cls.serverThread:
log.info('Joining real-time logging server thread.')
cls.serverThread.join()
cls.serverThread = None
for k in list(os.environ.keys()):
if k.startswith(cls.envPrefix):
os.environ.pop(k)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_stopLeader'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'id': '12', 'type': 'block', 'children': ['13', '19', '25']}; {'id': '13', 'type': 'assert_statement', 'children': ['14']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '18'], 'value': '>'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'initialized'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'augmented_assignment', 'children': ['21', '24'], 'value': '-='}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'initialized'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '31']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '30'], 'value': '=='}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'initialized'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'block', 'children': ['32', '58', '84']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'loggingServer'}; {'id': '36', 'type': 'block', 'children': ['37', '44', '52']}; {'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': 'log'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'Stopping real-time logging server.'"}; {'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': 'cls'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'loggingServer'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'shutdown'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'loggingServer'}; {'id': '57', 'type': 'None', 'children': []}; {'id': '58', 'type': 'if_statement', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'serverThread'}; {'id': '62', 'type': 'block', 'children': ['63', '70', '78']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'string', 'children': [], 'value': "'Joining real-time logging server thread.'"}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'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': 'cls'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'serverThread'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'serverThread'}; {'id': '83', 'type': 'None', 'children': []}; {'id': '84', 'type': 'for_statement', 'children': ['85', '86', '96']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '95']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '95', 'type': 'argument_list', 'children': []}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'if_statement', 'children': ['98', '106']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'envPrefix'}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '114']}; {'id': '109', 'type': 'attribute', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'k'}
|
Stop the server on the leader.
|
def router_deleted(self, context, routers):
LOG.debug('Got router deleted notification for %s', routers)
self._update_removed_routers_cache(routers)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'router_deleted'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'routers'}; {'id': '7', 'type': 'block', 'children': ['8', '16']}; {'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': 'LOG'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'Got router deleted notification for %s'"}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'routers'}; {'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': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_update_removed_routers_cache'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'routers'}
|
Deal with router deletion RPC message.
|
def html(self):
output = self.html_preamble
output += self._repr_html_()
output += self.html_post
return output
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'html'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '20', '26']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'html_preamble'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'augmented_assignment', 'children': ['14', '15'], 'value': '+='}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_repr_html_'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'augmented_assignment', 'children': ['22', '23'], 'value': '+='}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'html_post'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'output'}
|
Gives an html representation of the assessment.
|
def GetValue(self, row, col, table=None):
if table is None:
table = self.grid.current_table
try:
cell_code = self.code_array((row, col, table))
except IndexError:
cell_code = None
maxlength = int(config["max_textctrl_length"])
if cell_code is not None and len(cell_code) > maxlength:
chunk = 80
cell_code = "\n".join(cell_code[i:i + chunk]
for i in xrange(0, len(cell_code), chunk))
return cell_code
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetValue'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '24', '45', '54', '97']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'grid'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'current_table'}; {'id': '24', 'type': 'try_statement', 'children': ['25', '38']}; {'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': 'cell_code'}; {'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': 'code_array'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'tuple', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '38', 'type': 'except_clause', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cell_code'}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'maxlength'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"max_textctrl_length"'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '65']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '59'], 'value': 'and'}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'is not'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'cell_code'}; {'id': '58', 'type': 'None', 'children': []}; {'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': 'cell_code'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'maxlength'}; {'id': '65', 'type': 'block', 'children': ['66', '70']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'chunk'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '80'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'cell_code'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '77', 'type': 'generator_expression', 'children': ['78', '86']}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'cell_code'}; {'id': '80', 'type': 'slice', 'children': ['81', '82', '83']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '82', 'type': 'colon', 'children': []}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '+'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'chunk'}; {'id': '86', 'type': 'for_in_clause', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92', '96']}; {'id': '91', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'cell_code'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'chunk'}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'cell_code'}
|
Return the result value of a cell, line split if too much data
|
def data_recognise(self, data=None):
data = data or self.data
data_lower = data.lower()
if data_lower.startswith(u"http://") or data_lower.startswith(u"https://"):
return u'url'
elif data_lower.startswith(u"mailto:"):
return u'email'
elif data_lower.startswith(u"matmsg:to:"):
return u'emailmessage'
elif data_lower.startswith(u"tel:"):
return u'telephone'
elif data_lower.startswith(u"smsto:"):
return u'sms'
elif data_lower.startswith(u"mmsto:"):
return u'mms'
elif data_lower.startswith(u"geo:"):
return u'geo'
elif data_lower.startswith(u"mebkm:title:"):
return u'bookmark'
elif data_lower.startswith(u"mecard:"):
return u'phonebook'
else:
return u'text'
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_recognise'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '17', '25']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '12', 'type': 'boolean_operator', 'children': ['13', '14'], 'value': 'or'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '39', '42', '52', '62', '72', '82', '92', '102', '112', '122']}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '33'], 'value': 'or'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': 'u"http://"'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': 'u"https://"'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': "u'url'"}; {'id': '42', 'type': 'elif_clause', 'children': ['43', '49']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': 'u"mailto:"'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'string', 'children': [], 'value': "u'email'"}; {'id': '52', 'type': 'elif_clause', 'children': ['53', '59']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'string', 'children': [], 'value': 'u"matmsg:to:"'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'string', 'children': [], 'value': "u'emailmessage'"}; {'id': '62', 'type': 'elif_clause', 'children': ['63', '69']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'string', 'children': [], 'value': 'u"tel:"'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'string', 'children': [], 'value': "u'telephone'"}; {'id': '72', 'type': 'elif_clause', 'children': ['73', '79']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'string', 'children': [], 'value': 'u"smsto:"'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'string', 'children': [], 'value': "u'sms'"}; {'id': '82', 'type': 'elif_clause', 'children': ['83', '89']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'string', 'children': [], 'value': 'u"mmsto:"'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'string', 'children': [], 'value': "u'mms'"}; {'id': '92', 'type': 'elif_clause', 'children': ['93', '99']}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'string', 'children': [], 'value': 'u"geo:"'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'return_statement', 'children': ['101']}; {'id': '101', 'type': 'string', 'children': [], 'value': "u'geo'"}; {'id': '102', 'type': 'elif_clause', 'children': ['103', '109']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'string', 'children': [], 'value': 'u"mebkm:title:"'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'return_statement', 'children': ['111']}; {'id': '111', 'type': 'string', 'children': [], 'value': "u'bookmark'"}; {'id': '112', 'type': 'elif_clause', 'children': ['113', '119']}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'data_lower'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'string', 'children': [], 'value': 'u"mecard:"'}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'string', 'children': [], 'value': "u'phonebook'"}; {'id': '122', 'type': 'else_clause', 'children': ['123']}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'return_statement', 'children': ['125']}; {'id': '125', 'type': 'string', 'children': [], 'value': "u'text'"}
|
Returns an unicode string indicating the data type of the data paramater
|
def _freemem(conn):
mem = conn.getInfo()[1]
mem -= 256
for dom in _get_domain(conn, iterable=True):
if dom.ID() > 0:
mem -= dom.info()[2] / 1024
return mem
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_freemem'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '20', '51']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'mem'}; {'id': '9', 'type': 'subscript', 'children': ['10', '15']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'getInfo'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'augmented_assignment', 'children': ['18', '19'], 'value': '-='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'mem'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '29']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'dom'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_get_domain'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'iterable'}; {'id': '28', 'type': 'True', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '38']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '37'], 'value': '>'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dom'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'augmented_assignment', 'children': ['41', '42'], 'value': '-='}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'mem'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '50'], 'value': '/'}; {'id': '43', 'type': 'subscript', 'children': ['44', '49']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'dom'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '1024'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'mem'}
|
Internal variant of freemem taking a libvirt connection as parameter
|
def compare(operator,a,b):
"this could be replaced by overloading but I want == to return a bool for 'in' use"
f=({'=':lambda a,b:a==b,'!=':lambda a,b:a!=b,'>':lambda a,b:a>b,'<':lambda a,b:a<b}[operator])
return ThreeVL('u') if None in (a,b) else f(a,b)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compare'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '7', 'type': 'block', 'children': ['8', '10', '53']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'string', 'children': [], 'value': '"this could be replaced by overloading but I want == to return a bool for \'in\' use"'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'subscript', 'children': ['15', '52']}; {'id': '15', 'type': 'dictionary', 'children': ['16', '25', '34', '43']}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '18', 'type': 'lambda', 'children': ['19', '22']}; {'id': '19', 'type': 'lambda_parameters', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': '=='}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'!='"}; {'id': '27', 'type': 'lambda', 'children': ['28', '31']}; {'id': '28', 'type': 'lambda_parameters', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': '!='}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'>'"}; {'id': '36', 'type': 'lambda', 'children': ['37', '40']}; {'id': '37', 'type': 'lambda_parameters', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': '>'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'<'"}; {'id': '45', 'type': 'lambda', 'children': ['46', '49']}; {'id': '46', 'type': 'lambda_parameters', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': '<'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'conditional_expression', 'children': ['55', '59', '64'], 'value': 'if'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ThreeVL'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'u'"}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': 'in'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'tuple', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'b'}
|
this could be replaced by overloading but I want == to return a bool for 'in' use
|
def read(path, savedir):
" Read file from path "
if path.startswith('http://'):
name = op.basename(path)
save_path = op.join(savedir, name)
if not op.exists(save_path):
src = urllib2.urlopen(path).read()
try:
open(save_path, 'w').write(src)
except IOError:
return src
path = save_path
return open(path, 'r').read()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'savedir'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '80']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '" Read file from path "'}; {'id': '9', 'type': 'if_statement', 'children': ['10', '16']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'http://'"}; {'id': '16', 'type': 'block', 'children': ['17', '26', '36', '76']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'save_path'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'savedir'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '44']}; {'id': '37', 'type': 'not_operator', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'save_path'}; {'id': '44', 'type': 'block', 'children': ['45', '58']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '48', 'type': 'call', 'children': ['49', '57']}; {'id': '49', 'type': 'attribute', 'children': ['50', '56']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'urllib2'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'urlopen'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'try_statement', 'children': ['59', '71']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '69']}; {'id': '62', 'type': 'attribute', 'children': ['63', '68']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'save_path'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '71', 'type': 'except_clause', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'save_path'}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '89']}; {'id': '82', 'type': 'attribute', 'children': ['83', '88']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '89', 'type': 'argument_list', 'children': []}
|
Read file from path
|
def closed(self, user):
decision = False
for record in self.history:
if record["when"] < self.options.since.date:
continue
if not decision and record["when"] < self.options.until.date:
for change in record["changes"]:
if (change["field_name"] == "status"
and change["added"] == "CLOSED"
and record["who"] in [user.email, user.name]):
decision = True
else:
for change in record["changes"]:
if (change["field_name"] == "status"
and change["removed"] == "CLOSED"):
decision = False
return decision
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'closed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '109']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'decision'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '16']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'history'}; {'id': '16', 'type': 'block', 'children': ['17', '31']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '29']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': '<'}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"when"'}; {'id': '22', 'type': 'attribute', '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': 'options'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'since'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'continue_statement', 'children': []}; {'id': '31', 'type': 'if_statement', 'children': ['32', '46', '83']}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '35'], 'value': 'and'}; {'id': '33', 'type': 'not_operator', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'decision'}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '39'], 'value': '<'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"when"'}; {'id': '39', 'type': 'attribute', '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': 'options'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'until'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'for_statement', 'children': ['48', '49', '52']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'change'}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"changes"'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'if_statement', 'children': ['54', '78']}; {'id': '54', 'type': '()', 'children': ['55']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '67'], 'value': 'and'}; {'id': '56', 'type': 'boolean_operator', 'children': ['57', '62'], 'value': 'and'}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '61'], 'value': '=='}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'change'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"field_name"'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"status"'}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '66'], 'value': '=='}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'change'}; {'id': '65', 'type': 'string', 'children': [], 'value': '"added"'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"CLOSED"'}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '71'], 'value': 'in'}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '70', 'type': 'string', 'children': [], 'value': '"who"'}; {'id': '71', 'type': 'list', 'children': ['72', '75'], 'value': '[user.email, user.name]'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'decision'}; {'id': '82', 'type': 'True', 'children': []}; {'id': '83', 'type': 'else_clause', 'children': ['84']}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'for_statement', 'children': ['86', '87', '90']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'change'}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '89', 'type': 'string', 'children': [], 'value': '"changes"'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'if_statement', 'children': ['92', '104']}; {'id': '92', 'type': '()', 'children': ['93']}; {'id': '93', 'type': 'boolean_operator', 'children': ['94', '99'], 'value': 'and'}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '98'], 'value': '=='}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'change'}; {'id': '97', 'type': 'string', 'children': [], 'value': '"field_name"'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"status"'}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '103'], 'value': '=='}; {'id': '100', 'type': 'subscript', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'change'}; {'id': '102', 'type': 'string', 'children': [], 'value': '"removed"'}; {'id': '103', 'type': 'string', 'children': [], 'value': '"CLOSED"'}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'decision'}; {'id': '108', 'type': 'False', 'children': []}; {'id': '109', 'type': 'return_statement', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'decision'}
|
Moved to CLOSED and not later moved to ASSIGNED
|
def _vertex_list_to_sframe(ls, id_column_name):
sf = SFrame()
if type(ls) == list:
cols = reduce(set.union, (set(v.attr.keys()) for v in ls))
sf[id_column_name] = [v.vid for v in ls]
for c in cols:
sf[c] = [v.attr.get(c) for v in ls]
elif type(ls) == Vertex:
sf[id_column_name] = [ls.vid]
for col, val in ls.attr.iteritems():
sf[col] = [val]
else:
raise TypeError('Vertices type {} is Not supported.'.format(type(ls)))
return sf
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_vertex_list_to_sframe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id_column_name'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '128']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sf'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'SFrame'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'if_statement', 'children': ['14', '20', '77', '113']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '19'], 'value': '=='}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '20', 'type': 'block', 'children': ['21', '44', '56']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'reduce'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'union'}; {'id': '30', 'type': 'generator_expression', 'children': ['31', '41']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'set'}; {'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': 'v'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sf'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'id_column_name'}; {'id': '49', 'type': 'list_comprehension', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'vid'}; {'id': '53', 'type': 'for_in_clause', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '56', 'type': 'for_statement', 'children': ['57', '58', '59']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'sf'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '65', 'type': 'list_comprehension', 'children': ['66', '74']}; {'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': 'v'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '74', 'type': 'for_in_clause', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '77', 'type': 'elif_clause', 'children': ['78', '84']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '83'], 'value': '=='}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Vertex'}; {'id': '84', 'type': 'block', 'children': ['85', '94']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '90']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sf'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'id_column_name'}; {'id': '90', 'type': 'list', 'children': ['91'], 'value': '[ls.vid]'}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'vid'}; {'id': '94', 'type': 'for_statement', 'children': ['95', '98', '105']}; {'id': '95', 'type': 'pattern_list', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '98', 'type': 'call', 'children': ['99', '104']}; {'id': '99', 'type': 'attribute', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '104', 'type': 'argument_list', 'children': []}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '111']}; {'id': '108', 'type': 'subscript', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'sf'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '111', 'type': 'list', 'children': ['112'], 'value': '[val]'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '113', 'type': 'else_clause', 'children': ['114']}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'raise_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': "'Vertices type {} is Not supported.'"}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'ls'}; {'id': '128', 'type': 'return_statement', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'sf'}
|
Convert a list of vertices into an SFrame.
|
def play_empty(self):
if self.vclient:
if self.streamer:
self.streamer.volume = 0
self.vclient.play_audio("\n".encode(), encode=False)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'play_empty'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'vclient'}; {'id': '10', 'type': 'block', 'children': ['11', '24']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'streamer'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', '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': 'streamer'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'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': 'vclient'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'play_audio'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '37']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '39', 'type': 'False', 'children': []}
|
Play blank audio to let Discord know we're still here
|
def SaveResourceUsage(self, status):
user_cpu = status.cpu_time_used.user_cpu_time
system_cpu = status.cpu_time_used.system_cpu_time
self.rdf_flow.cpu_time_used.user_cpu_time += user_cpu
self.rdf_flow.cpu_time_used.system_cpu_time += system_cpu
self.rdf_flow.network_bytes_sent += status.network_bytes_sent
if self.rdf_flow.cpu_limit:
user_cpu_total = self.rdf_flow.cpu_time_used.user_cpu_time
system_cpu_total = self.rdf_flow.cpu_time_used.system_cpu_time
if self.rdf_flow.cpu_limit < (user_cpu_total + system_cpu_total):
raise flow.FlowError("CPU limit exceeded for {} {}.".format(
self.rdf_flow.flow_class_name, self.rdf_flow.flow_id))
if (self.rdf_flow.network_bytes_limit and
self.rdf_flow.network_bytes_limit < self.rdf_flow.network_bytes_sent):
raise flow.FlowError("Network bytes limit exceeded {} {}.".format(
self.rdf_flow.flow_class_name, self.rdf_flow.flow_id))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'SaveResourceUsage'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '23', '33', '43', '53', '113']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'user_cpu'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cpu_time_used'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'user_cpu_time'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'system_cpu'}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cpu_time_used'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'system_cpu_time'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'augmented_assignment', 'children': ['25', '32'], 'value': '+='}; {'id': '25', 'type': 'attribute', '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': 'rdf_flow'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cpu_time_used'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'user_cpu_time'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'user_cpu'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'augmented_assignment', 'children': ['35', '42'], 'value': '+='}; {'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': 'rdf_flow'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'cpu_time_used'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'system_cpu_time'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'system_cpu'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'augmented_assignment', 'children': ['45', '50'], 'value': '+='}; {'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': 'rdf_flow'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'network_bytes_sent'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'network_bytes_sent'}; {'id': '53', 'type': 'if_statement', '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': 'rdf_flow'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cpu_limit'}; {'id': '59', 'type': 'block', 'children': ['60', '70', '80']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'user_cpu_total'}; {'id': '63', 'type': 'attribute', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'cpu_time_used'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'user_cpu_time'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'system_cpu_total'}; {'id': '73', 'type': 'attribute', 'children': ['74', '79']}; {'id': '74', 'type': 'attribute', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'cpu_time_used'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'system_cpu_time'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '91']}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '87'], 'value': '<'}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'cpu_limit'}; {'id': '87', 'type': '()', 'children': ['88']}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '+'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'user_cpu_total'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'system_cpu_total'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'raise_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'FlowError'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': '"CPU limit exceeded for {} {}."'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '108']}; {'id': '103', 'type': 'attribute', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'flow_class_name'}; {'id': '108', 'type': 'attribute', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'flow_id'}; {'id': '113', 'type': 'if_statement', 'children': ['114', '132']}; {'id': '114', 'type': '()', 'children': ['115']}; {'id': '115', 'type': 'boolean_operator', 'children': ['116', '121'], 'value': 'and'}; {'id': '116', 'type': 'attribute', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'network_bytes_limit'}; {'id': '121', 'type': 'comparison_operator', 'children': ['122', '127'], 'value': '<'}; {'id': '122', 'type': 'attribute', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'network_bytes_limit'}; {'id': '127', 'type': 'attribute', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'network_bytes_sent'}; {'id': '132', 'type': 'block', 'children': ['133']}; {'id': '133', 'type': 'raise_statement', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'FlowError'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'string', 'children': [], 'value': '"Network bytes limit exceeded {} {}."'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '143', 'type': 'argument_list', 'children': ['144', '149']}; {'id': '144', 'type': 'attribute', 'children': ['145', '148']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'flow_class_name'}; {'id': '149', 'type': 'attribute', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'rdf_flow'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'flow_id'}
|
Method to tally resources.
|
def _path2point(path):
return {_VARS[node.root]: int(node.hi is path[i+1])
for i, node in enumerate(path[:-1])}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_path2point'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'dictionary_comprehension', 'children': ['8', '26']}; {'id': '8', 'type': 'pair', 'children': ['9', '14']}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_VARS'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '21'], 'value': 'is'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'hi'}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '+'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '30']}; {'id': '27', 'type': 'pattern_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '35', 'type': 'slice', 'children': ['36', '37']}; {'id': '36', 'type': 'colon', 'children': []}; {'id': '37', 'type': 'unary_operator', 'children': ['38'], 'value': '-'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}
|
Convert a BDD path to a BDD point.
|
def quaternion(vector, angle):
return N.cos(angle/2)+vector*N.sin(angle/2)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'quaternion'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'binary_operator', 'children': ['9', '17'], 'value': '+'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '16'], 'value': '/'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '19'], 'value': '*'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '/'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '2'}
|
Unit quaternion for a vector and an angle
|
def download_file(self, url, filename):
self.print_message("Downloading to file '%s' from URL '%s'" % (filename, url))
try:
db_file = urllib2.urlopen(url)
with open(filename, 'wb') as output:
output.write(db_file.read())
db_file.close()
except Exception as e:
self.error(str(e))
self.print_message("File downloaded")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'download_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '75']}; {'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': 'print_message'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '16'], 'value': '%'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"Downloading to file \'%s\' from URL \'%s\'"'}; {'id': '16', 'type': 'tuple', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '19', 'type': 'try_statement', 'children': ['20', '59']}; {'id': '20', 'type': 'block', 'children': ['21', '30', '53']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'db_file'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'urllib2'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'urlopen'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '30', 'type': 'with_statement', 'children': ['31', '41']}; {'id': '31', 'type': 'with_clause', 'children': ['32']}; {'id': '32', 'type': 'with_item', 'children': ['33']}; {'id': '33', 'type': 'as_pattern', 'children': ['34', '39']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'wb'"}; {'id': '39', 'type': 'as_pattern_target', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'db_file'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'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': 'db_file'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'id': '59', 'type': 'except_clause', 'children': ['60', '64']}; {'id': '60', 'type': 'as_pattern', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '62', 'type': 'as_pattern_target', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', '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': 'error'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'print_message'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'string', 'children': [], 'value': '"File downloaded"'}
|
Download file from url to filename.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.