code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def primary_from_id(self, tax_id):
s = select([self.names.c.tax_name],
and_(self.names.c.tax_id == tax_id,
self.names.c.is_primary))
res = s.execute()
output = res.fetchone()
if not output:
msg = 'value "{}" not found in names.tax_id'.format(tax_id)
raise ValueError(msg)
else:
return output[0]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'primary_from_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tax_id'}; {'id': '6', 'type': 'block', 'children': ['7', '40', '48', '56']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '21']}; {'id': '13', 'type': 'list', 'children': ['14'], 'value': '[self.names.c.tax_name]'}; {'id': '14', 'type': 'attribute', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'tax_name'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'and_'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '33']}; {'id': '24', 'type': 'comparison_operator', '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': 'names'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tax_id'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tax_id'}; {'id': '33', 'type': 'attribute', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'is_primary'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'fetchone'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'if_statement', 'children': ['57', '59', '74']}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '59', 'type': 'block', 'children': ['60', '69']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'string', 'children': [], 'value': '\'value "{}" not found in names.tax_id\''}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'tax_id'}; {'id': '69', 'type': 'raise_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '74', 'type': 'else_clause', 'children': ['75']}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '0'}
|
Returns primary taxonomic name associated with tax_id
|
def makedev(self, tarinfo, targetpath):
if not hasattr(os, "mknod") or not hasattr(os, "makedev"):
raise ExtractError("special devices not supported by system")
mode = tarinfo.mode
if tarinfo.isblk():
mode |= stat.S_IFBLK
else:
mode |= stat.S_IFCHR
os.mknod(targetpath, mode,
os.makedev(tarinfo.devmajor, tarinfo.devminor))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'makedev'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tarinfo'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'targetpath'}; {'id': '7', 'type': 'block', 'children': ['8', '28', '34', '55']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '22']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '16'], 'value': 'or'}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"mknod"'}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"makedev"'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'raise_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ExtractError'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"special devices not supported by system"'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tarinfo'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '40', '47']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'tarinfo'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'isblk'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'augmented_assignment', 'children': ['43', '44'], 'value': '|='}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'S_IFBLK'}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'augmented_assignment', 'children': ['51', '52'], 'value': '|='}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'S_IFCHR'}; {'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': 'os'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'mknod'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'targetpath'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'makedev'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'tarinfo'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'devmajor'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'tarinfo'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'devminor'}
|
Make a character or block device called targetpath.
|
def save_updates(self):
if not self._track_changes:
return True
url = self.build_url(self._endpoints.get('update_list_item').format(item_id=self.object_id))
update = {field: value for field, value in self.fields.items()
if self._cc(field) in self._track_changes}
response = self.con.patch(url, update)
if not response:
return False
self._clear_tracker()
return True
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_updates'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '39', '68', '80', '86', '92']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_track_changes'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'url'}; {'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': 'build_url'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '33']}; {'id': '23', 'type': 'attribute', 'children': ['24', '32']}; {'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': '_endpoints'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'update_list_item'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'item_id'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'object_id'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '42', 'type': 'dictionary_comprehension', 'children': ['43', '46', '57']}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'for_in_clause', 'children': ['47', '50']}; {'id': '47', 'type': 'pattern_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'if_clause', 'children': ['58']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '65'], 'value': 'in'}; {'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': '_cc'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_track_changes'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'patch'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '83']}; {'id': '81', 'type': 'not_operator', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'False', 'children': []}; {'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': '_clear_tracker'}; {'id': '91', 'type': 'argument_list', 'children': []}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'True', 'children': []}
|
Save the updated fields to the cloud
|
def sync(self, force=None):
try:
if force:
sd = force
else:
sd = self.sync_dir()
if sd == self.SYNC_DIR.FILE_TO_RECORD:
if force and not self.exists():
return None
self.fs_to_record()
elif sd == self.SYNC_DIR.RECORD_TO_FILE:
self.record_to_fs()
else:
return None
self._dataset.config.sync[self.file_const][sd] = time.time()
return sd
except Exception as e:
self._bundle.rollback()
self._bundle.error("Failed to sync '{}': {}".format(self.file_const, e))
raise
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sync'}; {'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': 'force'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'try_statement', 'children': ['10', '96']}; {'id': '10', 'type': 'block', 'children': ['11', '28', '74', '94']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '13', '18']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sd'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '18', 'type': 'else_clause', 'children': ['19']}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sd'}; {'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': 'sync_dir'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'if_statement', 'children': ['29', '36', '55', '70']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sd'}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'SYNC_DIR'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'FILE_TO_RECORD'}; {'id': '36', 'type': 'block', 'children': ['37', '49']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '46']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '40'], 'value': 'and'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '40', 'type': 'not_operator', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'None', 'children': []}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'fs_to_record'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'elif_clause', 'children': ['56', '63']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': '=='}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sd'}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'SYNC_DIR'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'RECORD_TO_FILE'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'record_to_fs'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'None', 'children': []}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '89']}; {'id': '76', 'type': 'subscript', 'children': ['77', '88']}; {'id': '77', 'type': 'subscript', 'children': ['78', '85']}; {'id': '78', 'type': 'attribute', 'children': ['79', '84']}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_dataset'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'sync'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'file_const'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sd'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '93', 'type': 'argument_list', 'children': []}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'sd'}; {'id': '96', 'type': 'except_clause', 'children': ['97', '101']}; {'id': '97', 'type': 'as_pattern', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '99', 'type': 'as_pattern_target', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '101', 'type': 'block', 'children': ['102', '110', '127']}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': '_bundle'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'rollback'}; {'id': '109', 'type': 'argument_list', 'children': []}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '117']}; {'id': '112', 'type': 'attribute', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': '_bundle'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'string', 'children': [], 'value': '"Failed to sync \'{}\': {}"'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'file_const'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '127', 'type': 'raise_statement', 'children': []}
|
Synchronize between the file in the file system and the field record
|
def readTableFromCSV(f, dialect="excel"):
rowNames = []
columnNames = []
matrix = []
first = True
for row in csv.reader(f, dialect):
if first:
columnNames = row[1:]
first = False
else:
rowNames.append(row[0])
matrix.append([float(c) for c in row[1:]])
return Table(rowNames, columnNames, matrix)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'readTableFromCSV'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '7', 'type': 'string', 'children': [], 'value': '"excel"'}; {'id': '8', 'type': 'block', 'children': ['9', '13', '17', '21', '25', '79']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'rowNames'}; {'id': '12', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'columnNames'}; {'id': '16', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'matrix'}; {'id': '20', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '24', 'type': 'True', 'children': []}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '34']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'csv'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '37', '50']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '37', 'type': 'block', 'children': ['38', '46']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'columnNames'}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '43', 'type': 'slice', 'children': ['44', '45']}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'colon', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '49', 'type': 'False', 'children': []}; {'id': '50', 'type': 'else_clause', 'children': ['51']}; {'id': '51', 'type': 'block', 'children': ['52', '61']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'rowNames'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'matrix'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'list_comprehension', 'children': ['68', '72']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '72', 'type': 'for_in_clause', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '76', 'type': 'slice', 'children': ['77', '78']}; {'id': '77', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '78', 'type': 'colon', 'children': []}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84', '85']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'rowNames'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'columnNames'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'matrix'}
|
Reads a table object from given CSV file.
|
def _parse_blkio_metrics(self, stats):
metrics = {
'io_read': 0,
'io_write': 0,
}
for line in stats:
if 'Read' in line:
metrics['io_read'] += int(line.split()[2])
if 'Write' in line:
metrics['io_write'] += int(line.split()[2])
return metrics
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_blkio_metrics'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '61']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '10', 'type': 'dictionary', 'children': ['11', '14']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'io_read'"}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'pair', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'io_write'"}; {'id': '16', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '20', 'type': 'block', 'children': ['21', '41']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '25']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': 'in'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'Read'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'augmented_assignment', 'children': ['28', '31'], 'value': '+='}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'io_read'"}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'subscript', 'children': ['35', '40']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '41', 'type': 'if_statement', 'children': ['42', '45']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'in'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'Write'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'augmented_assignment', 'children': ['48', '51'], 'value': '+='}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'io_write'"}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'subscript', 'children': ['55', '60']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'metrics'}
|
Parse the blkio metrics.
|
def preview_stream(stream):
_cv2.startWindowThread()
for frame in stream.frame_generator():
if frame is not None:
_cv2.imshow('Video', frame)
_cv2.moveWindow('Video',5,5)
else:
break
key = _cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
_cv2.waitKey(1)
_cv2.destroyAllWindows()
_cv2.waitKey(1)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'preview_stream'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '65', '72', '78']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_cv2'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'startWindowThread'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'for_statement', 'children': ['13', '14', '19']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'frame_generator'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20', '45', '56']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24', '42']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': 'is not'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25', '33']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_cv2'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'imshow'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'Video'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_cv2'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'moveWindow'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40', '41']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'Video'"}; {'id': '40', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '42', 'type': 'else_clause', 'children': ['43']}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'break_statement', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '55'], 'value': '&'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_cv2'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'waitKey'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0xFF'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '63']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '59'], 'value': '=='}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'ord'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': '"q"'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'break_statement', 'children': []}; {'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': '_cv2'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'waitKey'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'integer', 'children': [], 'value': '1'}; {'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': '_cv2'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'destroyAllWindows'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': '_cv2'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'waitKey'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'integer', 'children': [], 'value': '1'}
|
Display stream in an OpenCV window until "q" key is pressed
|
def _close(self, name, suppress_logging):
try:
pool_names = list(self.pools)
if name in pool_names:
self.pools[name].close()
del self.pools[name]
except Exception as e:
self.logger.error('Exception on closing Flopsy Pool for {0}: {1}'.format(name, e),
exc_info=not suppress_logging)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_close'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'suppress_logging'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '40']}; {'id': '9', 'type': 'block', 'children': ['10', '19']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pool_names'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pools'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'in'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pool_names'}; {'id': '23', 'type': 'block', 'children': ['24', '34']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '33']}; {'id': '26', 'type': 'attribute', 'children': ['27', '32']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'pools'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'delete_statement', 'children': ['35']}; {'id': '35', 'type': 'subscript', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'pools'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'except_clause', 'children': ['41', '45']}; {'id': '41', 'type': 'as_pattern', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '43', 'type': 'as_pattern_target', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'e'}; {'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': 'logger'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '61']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'Exception on closing Flopsy Pool for {0}: {1}'"}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'exc_info'}; {'id': '63', 'type': 'not_operator', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'suppress_logging'}
|
closes one particular pool and all its amqp amqp connections
|
def stripped_name(self):
name = self.name
while True:
name, n = self._parenthesis_re.subn('', name)
if not n:
break
name = self._const_re.sub('', name)
while True:
name, n = self._angles_re.subn('', name)
if not n:
break
return name
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stripped_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '34', '46', '68']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'while_statement', 'children': ['13', '14']}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '29']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_parenthesis_re'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'subn'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "''"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '32']}; {'id': '30', 'type': 'not_operator', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'break_statement', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_const_re'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "''"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '46', 'type': 'while_statement', 'children': ['47', '48']}; {'id': '47', 'type': 'True', 'children': []}; {'id': '48', 'type': 'block', 'children': ['49', '63']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '54']}; {'id': '51', 'type': 'pattern_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_angles_re'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'subn'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "''"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '66']}; {'id': '64', 'type': 'not_operator', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'break_statement', 'children': []}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Remove extraneous information from C++ demangled function names.
|
def add_to_parent(self):
parent = self.parent
if parent is not None:
try:
children = parent.children
except AttributeError: pass
else:
include(children, self)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_to_parent'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '16']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'is not'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'try_statement', 'children': ['18', '25', '29']}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '25', 'type': 'except_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'pass_statement', 'children': []}; {'id': '29', 'type': 'else_clause', 'children': ['30']}; {'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': 'include'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}
|
Adds this node to the parent's ``children`` collection if it exists.
|
def build_attrs(self, *args, **kwargs):
"Helper function for building an attribute dictionary."
self.attrs = self.widget.build_attrs(*args, **kwargs)
return self.attrs
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_attrs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '12', '28']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"Helper function for building an attribute dictionary."'}; {'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': 'attrs'}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'widget'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'build_attrs'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '26']}; {'id': '24', 'type': 'list_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '26', 'type': 'dictionary_splat', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'attrs'}
|
Helper function for building an attribute dictionary.
|
def ConsultarRemito(self, cod_remito=None, id_req=None,
tipo_comprobante=None, punto_emision=None, nro_comprobante=None):
"Obtener los datos de un remito generado"
print(self.client.help("consultarRemito"))
response = self.client.consultarRemito(
authRequest={'token': self.Token, 'sign': self.Sign, 'cuitRepresentada': self.Cuit},
codRemito=cod_remito,
idReq=id_req,
tipoComprobante=tipo_comprobante,
puntoEmision=punto_emision,
nroComprobante=nro_comprobante)
ret = response.get("consultarRemitoReturn", {})
id_req = ret.get("idReq", 0)
self.remito = rec = ret.get("remito", {})
self.__analizar_errores(ret)
self.__analizar_observaciones(ret)
self.__analizar_evento(ret)
self.AnalizarRemito(rec)
return id_req
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ConsultarRemito'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cod_remito'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'id_req'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tipo_comprobante'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'punto_emision'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'nro_comprobante'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '23', '35', '78', '88', '98', '112', '119', '126', '133', '140']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"Obtener los datos de un remito generado"'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"consultarRemito"'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'consultarRemito'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '63', '66', '69', '72', '75']}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'authRequest'}; {'id': '47', 'type': 'dictionary', 'children': ['48', '53', '58']}; {'id': '48', 'type': 'pair', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'token'"}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'Token'}; {'id': '53', 'type': 'pair', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'sign'"}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'Sign'}; {'id': '58', 'type': 'pair', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'cuitRepresentada'"}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'Cuit'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'codRemito'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cod_remito'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'idReq'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'id_req'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'tipoComprobante'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'tipo_comprobante'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'puntoEmision'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'punto_emision'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'nroComprobante'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'nro_comprobante'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': '"consultarRemitoReturn"'}; {'id': '87', 'type': 'dictionary', 'children': []}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'id_req'}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': '"idReq"'}; {'id': '97', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'remito'}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111']}; {'id': '110', 'type': 'string', 'children': [], 'value': '"remito"'}; {'id': '111', 'type': 'dictionary', 'children': []}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': '__analizar_errores'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': '__analizar_observaciones'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'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': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '__analizar_evento'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'AnalizarRemito'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '140', 'type': 'return_statement', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'id_req'}
|
Obtener los datos de un remito generado
|
def run(self):
while not self._abort:
hashes = self._GetHashes(self._hash_queue, self.hashes_per_batch)
if hashes:
time_before_analysis = time.time()
hash_analyses = self.Analyze(hashes)
current_time = time.time()
self.seconds_spent_analyzing += current_time - time_before_analysis
self.analyses_performed += 1
for hash_analysis in hash_analyses:
self._hash_analysis_queue.put(hash_analysis)
self._hash_queue.task_done()
time.sleep(self.wait_after_analysis)
else:
time.sleep(self.EMPTY_QUEUE_WAIT_TIME)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'while_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_abort'}; {'id': '11', 'type': 'block', 'children': ['12', '26']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'hashes'}; {'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': '_GetHashes'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_hash_queue'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hashes_per_batch'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '28', '98']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'hashes'}; {'id': '28', 'type': 'block', 'children': ['29', '37', '46', '54', '62', '68', '89']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'time_before_analysis'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'hash_analyses'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Analyze'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'hashes'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'current_time'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'augmented_assignment', 'children': ['56', '59'], 'value': '+='}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'seconds_spent_analyzing'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '-'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'current_time'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'time_before_analysis'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'augmented_assignment', 'children': ['64', '67'], 'value': '+='}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'analyses_performed'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'for_statement', 'children': ['69', '70', '71']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'hash_analysis'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'hash_analyses'}; {'id': '71', 'type': 'block', 'children': ['72', '81']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', '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': '_hash_analysis_queue'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'hash_analysis'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '88']}; {'id': '83', 'type': 'attribute', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_hash_queue'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'task_done'}; {'id': '88', 'type': 'argument_list', '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': 'time'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'wait_after_analysis'}; {'id': '98', 'type': 'else_clause', 'children': ['99']}; {'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': 'time'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'EMPTY_QUEUE_WAIT_TIME'}
|
The method called by the threading library to start the thread.
|
def remove_external_references(self):
for ex_ref_node in self.node.findall('externalReferences'):
self.node.remove(ex_ref_node)
|
{'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'}; {'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': 'ex_ref_node'}; {'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': "'externalReferences'"}; {'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': 'node'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ex_ref_node'}
|
Removes any external reference from the role
|
def label(self) -> str:
label = self.expression.replace("_", "\\;")
if self.units_kind:
symbol = wt_units.get_symbol(self.units)
for v in self.variables:
vl = "%s_{%s}" % (symbol, v.label)
vl = vl.replace("_{}", "")
label = label.replace(v.natural_name, vl)
val = (
round(self.value, self.round_spec)
if self.round_spec is not None
else self.value
)
label += r"\,=\,{}".format(format(val, self.format_spec))
if self.units_kind:
units_dictionary = getattr(wt_units, self.units_kind)
label += r"\,"
label += units_dictionary[self.units][2]
label = r"$\mathsf{%s}$" % label
return label
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'label'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '96', '111', '140', '146']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'label'}; {'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': 'expression'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"_"'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"\\\\;"'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'units_kind'}; {'id': '24', 'type': 'block', 'children': ['25', '36']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'wt_units'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get_symbol'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '36', 'type': 'for_statement', 'children': ['37', '38', '41']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '41', 'type': 'block', 'children': ['42', '52', '62', '74']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'vl'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '%'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"%s_{%s}"'}; {'id': '47', 'type': 'tuple', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'vl'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'vl'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': '"_{}"'}; {'id': '61', 'type': 'string', 'children': [], 'value': '""'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'natural_name'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'vl'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '77', 'type': '()', 'children': ['78']}; {'id': '78', 'type': 'conditional_expression', 'children': ['79', '88', '93'], 'value': 'if'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'round_spec'}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '92'], 'value': 'is not'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'round_spec'}; {'id': '92', 'type': 'None', 'children': []}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'augmented_assignment', 'children': ['98', '99'], 'value': '+='}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'string', 'children': [], 'value': 'r"\\,=\\,{}"'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'format_spec'}; {'id': '111', 'type': 'if_statement', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'units_kind'}; {'id': '115', 'type': 'block', 'children': ['116', '126', '130']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'units_dictionary'}; {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '121', 'type': 'argument_list', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'wt_units'}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'units_kind'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'augmented_assignment', 'children': ['128', '129'], 'value': '+='}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '129', 'type': 'string', 'children': [], 'value': 'r"\\,"'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'augmented_assignment', 'children': ['132', '133'], 'value': '+='}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '133', 'type': 'subscript', 'children': ['134', '139']}; {'id': '134', 'type': 'subscript', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'units_dictionary'}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '139', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}; {'id': '141', 'type': 'assignment', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '143', 'type': 'binary_operator', 'children': ['144', '145'], 'value': '%'}; {'id': '144', 'type': 'string', 'children': [], 'value': 'r"$\\mathsf{%s}$"'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '146', 'type': 'return_statement', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'label'}
|
A latex formatted label representing constant expression and united value.
|
def _unpack_episode(element: ET.Element):
return Episode(
epno=element.find('epno').text,
type=int(element.find('epno').get('type')),
length=int(element.find('length').text),
titles=tuple(_unpack_episode_title(title)
for title in element.iterfind('title')),
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_unpack_episode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ET'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Element'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Episode'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '25', '41', '54']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'epno'}; {'id': '17', 'type': 'attribute', 'children': ['18', '24']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'epno'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '39']}; {'id': '31', 'type': 'attribute', 'children': ['32', '38']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'epno'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'attribute', 'children': ['47', '53']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'length'"}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'titles'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '58', 'type': 'generator_expression', 'children': ['59', '63']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_unpack_episode_title'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '63', 'type': 'for_in_clause', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'iterfind'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'title'"}
|
Unpack Episode from episode XML element.
|
def declared_symbols(self):
return self.local_declared_symbols | (
self.parent.declared_symbols if self.parent else set())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'declared_symbols'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'binary_operator', 'children': ['8', '11'], 'value': '|'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'local_declared_symbols'}; {'id': '11', 'type': '()', 'children': ['12']}; {'id': '12', 'type': 'conditional_expression', 'children': ['13', '18', '21'], 'value': 'if'}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'declared_symbols'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '23', 'type': 'argument_list', 'children': []}
|
Return all local symbols here, and also of the parents
|
def load_private_key(pem_path, passphrase_bytes=None):
with open(pem_path, "rb") as f:
return cryptography.hazmat.primitives.serialization.load_pem_private_key(
data=f.read(),
password=passphrase_bytes,
backend=cryptography.hazmat.backends.default_backend(),
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_private_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pem_path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'passphrase_bytes'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'with_statement', 'children': ['10', '20']}; {'id': '10', 'type': 'with_clause', 'children': ['11']}; {'id': '11', 'type': 'with_item', 'children': ['12']}; {'id': '12', 'type': 'as_pattern', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pem_path'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"rb"'}; {'id': '18', 'type': 'as_pattern_target', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '32']}; {'id': '23', 'type': 'attribute', 'children': ['24', '31']}; {'id': '24', 'type': 'attribute', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cryptography'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'hazmat'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'primitives'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'serialization'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'load_pem_private_key'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '40', '43']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'passphrase_bytes'}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '45', 'type': 'call', 'children': ['46', '53']}; {'id': '46', 'type': 'attribute', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cryptography'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'hazmat'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'backends'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'default_backend'}; {'id': '53', 'type': 'argument_list', 'children': []}
|
Load private key from PEM encoded file
|
def rapl_read():
basenames = glob.glob('/sys/class/powercap/intel-rapl:*/')
basenames = sorted(set({x for x in basenames}))
pjoin = os.path.join
ret = list()
for path in basenames:
name = None
try:
name = cat(pjoin(path, 'name'), fallback=None, binary=False)
except (IOError, OSError, ValueError) as err:
logging.warning("ignoring %r for file %r",
(err, path), RuntimeWarning)
continue
if name:
try:
current = cat(pjoin(path, 'energy_uj'))
max_reading = 0.0
ret.append(RaplStats(name, float(current), max_reading))
except (IOError, OSError, ValueError) as err:
logging.warning("ignoring %r for file %r",
(err, path), RuntimeWarning)
return ret
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rapl_read'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '28', '36', '42', '145']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'basenames'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'/sys/class/powercap/intel-rapl:*/'"}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'basenames'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'set_comprehension', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'basenames'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'pjoin'}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'for_statement', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'basenames'}; {'id': '45', 'type': 'block', 'children': ['46', '50', '90']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'try_statement', 'children': ['51', '69']}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'cat'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '63', '66']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pjoin'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'fallback'}; {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'binary'}; {'id': '68', 'type': 'False', 'children': []}; {'id': '69', 'type': 'except_clause', 'children': ['70', '77']}; {'id': '70', 'type': 'as_pattern', 'children': ['71', '75']}; {'id': '71', 'type': 'tuple', 'children': ['72', '73', '74']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '75', 'type': 'as_pattern_target', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '77', 'type': 'block', 'children': ['78', '89']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '85', '88']}; {'id': '84', 'type': 'string', 'children': [], 'value': '"ignoring %r for file %r"'}; {'id': '85', 'type': 'tuple', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'RuntimeWarning'}; {'id': '89', 'type': 'continue_statement', 'children': []}; {'id': '90', 'type': 'if_statement', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'try_statement', 'children': ['94', '125']}; {'id': '94', 'type': 'block', 'children': ['95', '106', '110']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '98', 'type': 'call', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'cat'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'pjoin'}; {'id': '103', 'type': 'argument_list', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '105', 'type': 'string', 'children': [], 'value': "'energy_uj'"}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'max_reading'}; {'id': '109', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'RaplStats'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120', '124']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'max_reading'}; {'id': '125', 'type': 'except_clause', 'children': ['126', '133']}; {'id': '126', 'type': 'as_pattern', 'children': ['127', '131']}; {'id': '127', 'type': 'tuple', 'children': ['128', '129', '130']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '131', 'type': 'as_pattern_target', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '133', 'type': 'block', 'children': ['134']}; {'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': 'logging'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141', '144']}; {'id': '140', 'type': 'string', 'children': [], 'value': '"ignoring %r for file %r"'}; {'id': '141', 'type': 'tuple', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'RuntimeWarning'}; {'id': '145', 'type': 'return_statement', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'ret'}
|
Read power stats and return dictionary
|
def post_save_stop(sender, instance, **kwargs):
from multigtfs.models.trip import Trip
trip_ids = instance.stoptime_set.filter(
trip__shape=None).values_list('trip_id', flat=True).distinct()
for trip in Trip.objects.filter(id__in=trip_ids):
trip.update_geometry()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post_save_stop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sender'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '16', '41']}; {'id': '9', 'type': 'import_from_statement', 'children': ['10', '14']}; {'id': '10', 'type': 'dotted_name', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'multigtfs'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'trip'}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Trip'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'trip_ids'}; {'id': '19', 'type': 'call', 'children': ['20', '40']}; {'id': '20', 'type': 'attribute', 'children': ['21', '39']}; {'id': '21', 'type': 'call', 'children': ['22', '34']}; {'id': '22', 'type': 'attribute', 'children': ['23', '33']}; {'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': 'instance'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'stoptime_set'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'trip__shape'}; {'id': '32', 'type': 'None', 'children': []}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'values_list'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'trip_id'"}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'flat'}; {'id': '38', 'type': 'True', 'children': []}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'distinct'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'for_statement', 'children': ['42', '43', '53']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'trip'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Trip'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'id__in'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'trip_ids'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'trip'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'update_geometry'}; {'id': '59', 'type': 'argument_list', 'children': []}
|
Update related objects when the Stop is updated
|
def _next_offset(self):
if self._filestream:
offset = self._filestream.tell()
if offset:
offset -= 1
else:
offset = self._initial_offset
return offset
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_next_offset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '36']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10', '28']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_filestream'}; {'id': '10', 'type': 'block', 'children': ['11', '21']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_filestream'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tell'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'if_statement', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'augmented_assignment', 'children': ['26', '27'], 'value': '-='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '28', 'type': 'else_clause', 'children': ['29']}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_initial_offset'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'offset'}
|
Return the offset of the next line to read.
|
def initializable(self):
return bool(lib.EnvSlotInitableP(self._env, self._cls, self._name))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initializable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'lib'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'EnvSlotInitableP'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18', '21']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_env'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_cls'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_name'}
|
True if the Slot is initializable.
|
def second_textx_model(self, model_parser):
if self.grammar_parser.debug:
self.grammar_parser.dprint("RESOLVING MODEL PARSER: second_pass")
self._resolve_rule_refs(self.grammar_parser, model_parser)
self._determine_rule_types(model_parser.metamodel)
self._resolve_cls_refs(self.grammar_parser, model_parser)
return model_parser
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'second_textx_model'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'model_parser'}; {'id': '6', 'type': 'block', 'children': ['7', '23', '33', '42', '52']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'grammar_parser'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'grammar_parser'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dprint'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"RESOLVING MODEL PARSER: second_pass"'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_resolve_rule_refs'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'grammar_parser'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'model_parser'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_determine_rule_types'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'model_parser'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'metamodel'}; {'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': '_resolve_cls_refs'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'grammar_parser'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'model_parser'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'model_parser'}
|
Cross reference resolving for parser model.
|
def iterativeFetch(query, batchSize=default_batch_size):
while True:
rows = query.fetchmany(batchSize)
if not rows:
break
rowDicts = sqliteRowsToDicts(rows)
for rowDict in rowDicts:
yield rowDict
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iterativeFetch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'batchSize'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default_batch_size'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'while_statement', 'children': ['10', '11']}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '21', '26', '33']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'fetchmany'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'batchSize'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '24']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'break_statement', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'rowDicts'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sqliteRowsToDicts'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'rowDict'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'rowDicts'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'yield', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'rowDict'}
|
Returns rows of a sql fetch query on demand
|
def embeddedFileUpd(self, id, buffer=None, filename=None, ufilename=None, desc=None):
return _fitz.Document_embeddedFileUpd(self, id, buffer, filename, ufilename, desc)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'embeddedFileUpd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'buffer'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ufilename'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_fitz'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Document_embeddedFileUpd'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '27', '28', '29', '30']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'buffer'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ufilename'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'desc'}
|
Change an embedded file given its entry number or name.
|
def gen_key(path):
cmd = 'ssh-keygen -P "" -f {0} -t rsa -q'.format(path)
if not os.path.isdir(os.path.dirname(path)):
os.makedirs(os.path.dirname(path))
subprocess.call(cmd, shell=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_key'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': '\'ssh-keygen -P "" -f {0} -t rsa -q\''}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '32']}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'call'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '56', 'type': 'True', 'children': []}
|
Generate a key for use with salt-ssh
|
def _zoom_labels(self, zoom):
labelfont = self.grid.GetLabelFont()
default_fontsize = get_default_font().GetPointSize()
labelfont.SetPointSize(max(1, int(round(default_fontsize * zoom))))
self.grid.SetLabelFont(labelfont)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_zoom_labels'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'zoom'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '27', '46']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'labelfont'}; {'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': 'grid'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'GetLabelFont'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'default_fontsize'}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_default_font'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'GetPointSize'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'labelfont'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'SetPointSize'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '*'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'default_fontsize'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'zoom'}; {'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': 'grid'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'SetLabelFont'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'labelfont'}
|
Adjust grid label font to zoom factor
|
def setup(sphinx):
create_auto_documentation()
from sphinx.highlighting import lexers
lexers['py3status'] = Py3statusLexer()
sphinx.add_directive('screenshot', ScreenshotDirective)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sphinx'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '16', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'create_auto_documentation'}; {'id': '9', 'type': 'argument_list', 'children': []}; {'id': '10', 'type': 'import_from_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'dotted_name', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'sphinx'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'highlighting'}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'lexers'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'lexers'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'py3status'"}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Py3statusLexer'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'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': 'sphinx'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'add_directive'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'screenshot'"}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ScreenshotDirective'}
|
This will be called by sphinx.
|
def _shorten_file_path(line):
start = line.lower().find('file')
if start < 0:
return line
first_quote = line.find('"', start)
if first_quote < 0:
return line
second_quote = line.find('"', first_quote + 1)
if second_quote < 0:
return line
path = line[first_quote + 1:second_quote]
new_path = '/'.join(path.split('/')[-3:])
return line[:first_quote] + '[...]/' + new_path + line[second_quote + 1:]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_shorten_file_path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '26', '36', '43', '55', '62', '73', '92']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'start'}; {'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': 'line'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'file'"}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': '<'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'first_quote'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '\'"\''}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '<'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'first_quote'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'second_quote'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': '\'"\''}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '+'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'first_quote'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '59']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': '<'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'second_quote'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '67', 'type': 'slice', 'children': ['68', '71', '72']}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '70'], 'value': '+'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'first_quote'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'colon', 'children': []}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'second_quote'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'new_path'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'subscript', 'children': ['82', '88']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '88', 'type': 'slice', 'children': ['89', '91']}; {'id': '89', 'type': 'unary_operator', 'children': ['90'], 'value': '-'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '91', 'type': 'colon', 'children': []}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '103'], 'value': '+'}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '102'], 'value': '+'}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '101'], 'value': '+'}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '98', 'type': 'slice', 'children': ['99', '100']}; {'id': '99', 'type': 'colon', 'children': []}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'first_quote'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'[...]/'"}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'new_path'}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '105', 'type': 'slice', 'children': ['106', '109']}; {'id': '106', 'type': 'binary_operator', 'children': ['107', '108'], 'value': '+'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'second_quote'}; {'id': '108', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '109', 'type': 'colon', 'children': []}
|
Shorten file path in error lines for more readable tracebacks.
|
def update(self, stats):
if self.generate_every != 0 and self._timer.finished():
self.args.generate_graph = True
self._timer.reset()
if not self.args.generate_graph:
return
plugins = stats.getPluginsList()
for plugin_name in plugins:
plugin = stats._plugins[plugin_name]
if plugin_name in self.plugins_to_export():
self.export(plugin_name, plugin.get_export_history())
logger.info("Graphs created in the folder {}".format(self.path))
self.args.generate_graph = False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '6', 'type': 'block', 'children': ['7', '38', '47', '55', '88', '102']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '21']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '14'], 'value': 'and'}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '13'], 'value': '!='}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'generate_every'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_timer'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'finished'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '30']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', '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': 'args'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'generate_graph'}; {'id': '29', 'type': 'True', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_timer'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'if_statement', 'children': ['39', '45']}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'generate_graph'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': []}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'plugins'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'getPluginsList'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'for_statement', 'children': ['56', '57', '58']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'plugin_name'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'plugins'}; {'id': '58', 'type': 'block', 'children': ['59', '67']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '62', 'type': 'subscript', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '_plugins'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'plugin_name'}; {'id': '67', 'type': 'if_statement', 'children': ['68', '75']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': 'in'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'plugin_name'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'plugins_to_export'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'export'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'plugin_name'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'get_export_history'}; {'id': '87', 'type': 'argument_list', 'children': []}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': '"Graphs created in the folder {}"'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'generate_graph'}; {'id': '109', 'type': 'False', 'children': []}
|
Generate Graph file in the output folder.
|
def find(self, node, path):
return node.find(path, namespaces=self.namespaces)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'namespaces'}
|
Wrapper for lxml`s find.
|
def _get_belief_package(stmt):
belief_packages = []
for st in stmt.supports:
parent_packages = _get_belief_package(st)
package_stmt_keys = [pkg.statement_key for pkg in belief_packages]
for package in parent_packages:
if package.statement_key not in package_stmt_keys:
belief_packages.append(package)
belief_package = BeliefPackage(stmt.matches_key(), stmt.evidence)
belief_packages.append(belief_package)
return belief_packages
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_belief_package'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'stmt'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '51', '65', '72']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'belief_packages'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '15']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'st'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'stmt'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'supports'}; {'id': '15', 'type': 'block', 'children': ['16', '23', '33']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parent_packages'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_get_belief_package'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'st'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'package_stmt_keys'}; {'id': '26', 'type': 'list_comprehension', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'statement_key'}; {'id': '30', 'type': 'for_in_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'belief_packages'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'parent_packages'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '43']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '42'], 'value': 'not in'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'statement_key'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'package_stmt_keys'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'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': 'belief_packages'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'belief_package'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'BeliefPackage'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '62']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'stmt'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'matches_key'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'stmt'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'evidence'}; {'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': 'belief_packages'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'belief_package'}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'belief_packages'}
|
Return the belief packages of a given statement recursively.
|
def should_filter(items):
return (vcfutils.get_paired(items) is not None and
any("damage_filter" in dd.get_tools_on(d) for d in items))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'should_filter'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': '()', 'children': ['8']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '17'], 'value': 'and'}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '16'], 'value': 'is not'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'vcfutils'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_paired'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '19', 'type': 'generator_expression', 'children': ['20', '28']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'in'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"damage_filter"'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dd'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get_tools_on'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '28', 'type': 'for_in_clause', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'items'}
|
Check if we should do damage filtering on somatic calling with low frequency events.
|
def configure_nodes(self):
required_nodes = self._get_required_nodes()
log.debug(
"Matching existing lb nodes to required %s (port %s)"
% (", ".join(required_nodes), self.backend_port)
)
self.consul.match_lb_nodes(
self.lb_attrs[A.loadbalancer.ID],
self.lb_attrs[A.loadbalancer.NODES_KEY],
required_nodes,
self.backend_port)
self.lb_attrs = self.consul.lb_details(
self.lb_attrs[A.loadbalancer.ID]
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'configure_nodes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '32', '62']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'required_nodes'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_get_required_nodes'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"Matching existing lb nodes to required %s (port %s)"'}; {'id': '22', 'type': 'tuple', 'children': ['23', '29']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'required_nodes'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'backend_port'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'consul'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'match_lb_nodes'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '49', '58', '59']}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'lb_attrs'}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'loadbalancer'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '49', 'type': 'subscript', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'lb_attrs'}; {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'loadbalancer'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'NODES_KEY'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'required_nodes'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'backend_port'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'lb_attrs'}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'consul'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'lb_details'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'subscript', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'lb_attrs'}; {'id': '78', 'type': 'attribute', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'loadbalancer'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'ID'}
|
Ensure that the LB's nodes matches the stack
|
def deconstruct(name):
name = coerce_unicode(name, _c.FSQ_CHARSET)
new_arg = sep = u''
args = []
if 1 > len(name):
raise FSQMalformedEntryError(errno.EINVAL, u'cannot derive delimiter'\
u'from: {0}'.format(name))
delimiter, encodeseq = delimiter_encodeseq(name[0], _c.FSQ_ENCODE,
_c.FSQ_CHARSET)
if 1 == len(name):
return delimiter, args
encoding_trg = sep
for c in name[1:]:
if 3 == len(encoding_trg):
encoding_trg = sep
if c == encodeseq or len(encoding_trg):
encoding_trg = sep.join([encoding_trg, c])
elif c == delimiter:
args.append(decode(new_arg, delimiter=delimiter,
encodeseq=encodeseq))
new_arg = sep
continue
new_arg = sep.join([new_arg, c])
args.append(decode(new_arg, delimiter=delimiter, encodeseq=encodeseq))
return delimiter, args
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deconstruct'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '22', '26', '49', '66', '78', '82', '160', '176']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'coerce_unicode'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_c'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'FSQ_CHARSET'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'new_arg'}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '21', 'type': 'string', 'children': [], 'value': "u''"}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '33']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': '>'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'raise_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'FSQMalformedEntryError'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'EINVAL'}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'concatenated_string', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "u'cannot derive delimiter'"}; {'id': '45', 'type': 'string', 'children': [], 'value': "u'from: {0}'"}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '54']}; {'id': '51', 'type': 'pattern_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'encodeseq'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'delimiter_encodeseq'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '60', '63']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': '_c'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'FSQ_ENCODE'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_c'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'FSQ_CHARSET'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '73']}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': '=='}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'expression_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'encoding_trg'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '82', 'type': 'for_statement', 'children': ['83', '84', '89']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '86', 'type': 'slice', 'children': ['87', '88']}; {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'colon', 'children': []}; {'id': '89', 'type': 'block', 'children': ['90', '102', '149']}; {'id': '90', 'type': 'if_statement', 'children': ['91', '97']}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': '=='}; {'id': '92', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'encoding_trg'}; {'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': 'encoding_trg'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '111', '123']}; {'id': '103', 'type': 'boolean_operator', 'children': ['104', '107'], 'value': 'or'}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '106'], 'value': '=='}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'encodeseq'}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'encoding_trg'}; {'id': '111', 'type': 'block', 'children': ['112']}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'encoding_trg'}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'list', 'children': ['121', '122'], 'value': '[encoding_trg, c]'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'encoding_trg'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '123', 'type': 'elif_clause', 'children': ['124', '127']}; {'id': '124', 'type': 'comparison_operator', 'children': ['125', '126'], 'value': '=='}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '127', 'type': 'block', 'children': ['128', '144', '148']}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '136', 'type': 'argument_list', 'children': ['137', '138', '141']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'new_arg'}; {'id': '138', 'type': 'keyword_argument', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '141', 'type': 'keyword_argument', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'encodeseq'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'encodeseq'}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}; {'id': '145', 'type': 'assignment', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'new_arg'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '148', 'type': 'continue_statement', 'children': []}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'new_arg'}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'list', 'children': ['158', '159'], 'value': '[new_arg, c]'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'new_arg'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'call', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '168', 'type': 'argument_list', 'children': ['169', '170', '173']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'new_arg'}; {'id': '170', 'type': 'keyword_argument', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '173', 'type': 'keyword_argument', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'encodeseq'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'encodeseq'}; {'id': '176', 'type': 'return_statement', 'children': ['177']}; {'id': '177', 'type': 'expression_list', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'delimiter'}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'args'}
|
Deconstruct a queue-name to a set of arguments
|
def object_ref(self):
return ImmutableDict(type=self.type, category_id=self.category_id, event_id=self.event_id,
session_id=self.session_id, contrib_id=self.contrib_id, subcontrib_id=self.subcontrib_id)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'object_ref'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ImmutableDict'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '15', '20', '25', '30', '35']}; {'id': '10', 'type': 'keyword_argument', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'category_id'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'category_id'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'event_id'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'event_id'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'session_id'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'session_id'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'contrib_id'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'contrib_id'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'subcontrib_id'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'subcontrib_id'}
|
Return the reference of the changed object.
|
def run_setup(setup_script, args):
setup_dir = os.path.abspath(os.path.dirname(setup_script))
with setup_context(setup_dir):
try:
sys.argv[:] = [setup_script] + list(args)
sys.path.insert(0, setup_dir)
working_set.__init__()
working_set.callbacks.append(lambda dist: dist.activate())
dunder_file = (
setup_script
if isinstance(setup_script, str) else
setup_script.encode(sys.getfilesystemencoding())
)
with DirectorySandbox(setup_dir):
ns = dict(__file__=dunder_file, __name__='__main__')
_execfile(setup_script, ns)
except SystemExit as v:
if v.args and v.args[0]:
raise
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_setup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'setup_script'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'setup_dir'}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'setup_script'}; {'id': '25', 'type': 'with_statement', 'children': ['26', '32']}; {'id': '26', 'type': 'with_clause', 'children': ['27']}; {'id': '27', 'type': 'with_item', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'setup_context'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'setup_dir'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'try_statement', 'children': ['34', '129']}; {'id': '34', 'type': 'block', 'children': ['35', '50', '60', '66', '82', '103']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '43']}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '41', 'type': 'slice', 'children': ['42']}; {'id': '42', 'type': 'colon', 'children': []}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '46'], 'value': '+'}; {'id': '44', 'type': 'list', 'children': ['45'], 'value': '[setup_script]'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'setup_script'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '57']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'setup_dir'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'working_set'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '__init__'}; {'id': '65', 'type': 'argument_list', 'children': []}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'working_set'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'callbacks'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'lambda', 'children': ['75', '77']}; {'id': '75', 'type': 'lambda_parameters', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'activate'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'dunder_file'}; {'id': '85', 'type': '()', 'children': ['86']}; {'id': '86', 'type': 'conditional_expression', 'children': ['87', '88', '93'], 'value': 'if'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'setup_script'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'setup_script'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'setup_script'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'getfilesystemencoding'}; {'id': '102', 'type': 'argument_list', 'children': []}; {'id': '103', 'type': 'with_statement', 'children': ['104', '110']}; {'id': '104', 'type': 'with_clause', 'children': ['105']}; {'id': '105', 'type': 'with_item', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'DirectorySandbox'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'setup_dir'}; {'id': '110', 'type': 'block', 'children': ['111', '123']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '114', 'type': 'call', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '120']}; {'id': '117', 'type': 'keyword_argument', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': '__file__'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'dunder_file'}; {'id': '120', 'type': 'keyword_argument', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '122', 'type': 'string', 'children': [], 'value': "'__main__'"}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': '_execfile'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'setup_script'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '129', 'type': 'except_clause', 'children': ['130', '134']}; {'id': '130', 'type': 'as_pattern', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'SystemExit'}; {'id': '132', 'type': 'as_pattern_target', 'children': ['133']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '134', 'type': 'block', 'children': ['135']}; {'id': '135', 'type': 'if_statement', 'children': ['136', '145']}; {'id': '136', 'type': 'boolean_operator', 'children': ['137', '140'], 'value': 'and'}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '140', 'type': 'subscript', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '144', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'raise_statement', 'children': []}
|
Run a distutils setup script, sandboxed in its directory
|
def interactive(outdir):
print("Building your Blended files into a website!")
global outdir_type
outdir_type = outdir
reload(sys)
sys.setdefaultencoding('utf8')
build_files(outdir)
print("Watching the content and templates directories for changes, press CTRL+C to stop...\n")
w = Watcher()
w.run()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interactive'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '13', '17', '22', '29', '34', '39', '45']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"Building your Blended files into a website!"'}; {'id': '11', 'type': 'global_statement', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'outdir_type'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'outdir_type'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'reload'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'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': 'sys'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'setdefaultencoding'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'utf8'"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'build_files'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'outdir'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"Watching the content and templates directories for changes, press CTRL+C to stop...\\n"'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Watcher'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '50', 'type': 'argument_list', 'children': []}
|
Blends the generated files and outputs a HTML website on file change
|
def validate_meta(meta):
if not isinstance(meta, (dict,)):
raise TypeError('Model Meta "linguist" must be a dict')
required_keys = ("identifier", "fields")
for key in required_keys:
if key not in meta:
raise KeyError('Model Meta "linguist" dict requires %s to be defined', key)
if not isinstance(meta["fields"], (list, tuple)):
raise ImproperlyConfigured(
"Linguist Meta's fields attribute must be a list or tuple"
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_meta'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '26', '41']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '12', 'type': 'tuple', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'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': 'TypeError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': '\'Model Meta "linguist" must be a dict\''}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'required_keys'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"identifier"'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"fields"'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '29']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'required_keys'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '34']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': 'not in'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'raise_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '\'Model Meta "linguist" dict requires %s to be defined\''}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '41', 'type': 'if_statement', 'children': ['42', '52']}; {'id': '42', 'type': 'not_operator', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"fields"'}; {'id': '49', 'type': 'tuple', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'raise_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ImproperlyConfigured'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"Linguist Meta\'s fields attribute must be a list or tuple"'}
|
Validates Linguist Meta attribute.
|
def delete_virtualip(self, loadbalancer, vip):
lb = vip.parent
if not lb:
raise exc.UnattachedVirtualIP("No parent Load Balancer for this "
"VirtualIP could be determined.")
resp, body = self.api.method_delete("/loadbalancers/%s/virtualips/%s" %
(lb.id, vip.id))
return resp, body
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_virtualip'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'loadbalancer'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'vip'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '27', '48']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lb'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'vip'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '17']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lb'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'raise_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'UnattachedVirtualIP'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'concatenated_string', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"No parent Load Balancer for this "'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"VirtualIP could be determined."'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'pattern_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'body'}; {'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': 'api'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'method_delete'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '%'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"/loadbalancers/%s/virtualips/%s"'}; {'id': '41', 'type': 'tuple', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'lb'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'vip'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'expression_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'body'}
|
Deletes the VirtualIP from its load balancer.
|
def setEngineRootOverride(self, rootDir):
ConfigurationManager.setConfigKey('rootDirOverride', os.path.abspath(rootDir))
try:
self.getEngineVersion()
except:
print('Warning: the specified directory does not appear to contain a valid version of the Unreal Engine.')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setEngineRootOverride'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rootDir'}; {'id': '6', 'type': 'block', 'children': ['7', '22']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ConfigurationManager'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'setConfigKey'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'rootDirOverride'"}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rootDir'}; {'id': '22', 'type': 'try_statement', 'children': ['23', '30']}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'getEngineVersion'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'except_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'Warning: the specified directory does not appear to contain a valid version of the Unreal Engine.'"}
|
Sets a user-specified directory as the root engine directory, overriding any auto-detection
|
def _extract_auth_config(self):
service = self._service
if not service.authentication:
return {}
auth_infos = {}
for auth_rule in service.authentication.rules:
selector = auth_rule.selector
provider_ids_to_audiences = {}
for requirement in auth_rule.requirements:
provider_id = requirement.providerId
if provider_id and requirement.audiences:
audiences = requirement.audiences.split(u",")
provider_ids_to_audiences[provider_id] = audiences
auth_infos[selector] = AuthInfo(provider_ids_to_audiences)
return auth_infos
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_extract_auth_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '20', '24', '87']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_service'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '17']}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'authentication'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'dictionary', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'auth_infos'}; {'id': '23', 'type': 'dictionary', 'children': []}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '31']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'auth_rule'}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'authentication'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'rules'}; {'id': '31', 'type': 'block', 'children': ['32', '38', '42', '78']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'auth_rule'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'provider_ids_to_audiences'}; {'id': '41', 'type': 'dictionary', 'children': []}; {'id': '42', 'type': 'for_statement', 'children': ['43', '44', '47']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'requirement'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'auth_rule'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'requirements'}; {'id': '47', 'type': 'block', 'children': ['48', '54']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'provider_id'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'requirement'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'providerId'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '60']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '57'], 'value': 'and'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'provider_id'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'requirement'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'audiences'}; {'id': '60', 'type': 'block', 'children': ['61', '72']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'audiences'}; {'id': '64', 'type': 'call', 'children': ['65', '70']}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'requirement'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'audiences'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'string', 'children': [], 'value': 'u","'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'provider_ids_to_audiences'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'provider_id'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'audiences'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '83']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'auth_infos'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'AuthInfo'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'provider_ids_to_audiences'}; {'id': '87', 'type': 'return_statement', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'auth_infos'}
|
Obtains the authentication configurations.
|
def serialize(self, value):
if six.PY2:
output = io.BytesIO()
csv.writer(output).writerow([unicode(x).encode('utf-8') for x in value])
serialized_value = output.getvalue().decode('utf-8').strip()
else:
output = io.StringIO()
csv.writer(output).writerow([str(x) for x in value])
serialized_value = output.getvalue().strip()
return _helpers.StrOrUnicode(serialized_value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialize'}; {'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', '102']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11', '61']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'PY2'}; {'id': '11', 'type': 'block', 'children': ['12', '20', '44']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'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': 'io'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'BytesIO'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '30']}; {'id': '22', 'type': 'attribute', 'children': ['23', '29']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'csv'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'writer'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'writerow'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'list_comprehension', 'children': ['32', '41']}; {'id': '32', 'type': 'call', 'children': ['33', '39']}; {'id': '33', 'type': 'attribute', 'children': ['34', '38']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'serialized_value'}; {'id': '47', 'type': 'call', 'children': ['48', '60']}; {'id': '48', 'type': 'attribute', 'children': ['49', '59']}; {'id': '49', 'type': 'call', 'children': ['50', '57']}; {'id': '50', 'type': 'attribute', 'children': ['51', '56']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'getvalue'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '60', 'type': 'argument_list', 'children': []}; {'id': '61', 'type': 'else_clause', 'children': ['62']}; {'id': '62', 'type': 'block', 'children': ['63', '71', '90']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'io'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'StringIO'}; {'id': '70', 'type': 'argument_list', 'children': []}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '81']}; {'id': '73', 'type': 'attribute', 'children': ['74', '80']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'csv'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'writer'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'writerow'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'list_comprehension', 'children': ['83', '87']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '87', 'type': 'for_in_clause', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'serialized_value'}; {'id': '93', 'type': 'call', 'children': ['94', '101']}; {'id': '94', 'type': 'attribute', 'children': ['95', '100']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'getvalue'}; {'id': '99', 'type': 'argument_list', 'children': []}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '101', 'type': 'argument_list', 'children': []}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': '_helpers'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'StrOrUnicode'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'serialized_value'}
|
Serialize a list as a string, if possible, or as a unicode string.
|
def echo_verbose_results(data, no_color):
click.echo()
click.echo(
'\n'.join(
'{}: {}'.format(key, val) for key, val in data['info'].items()
)
)
click.echo()
for test in data['tests']:
if test['outcome'] == 'passed':
fg = 'green'
elif test['outcome'] == 'skipped':
fg = 'yellow'
else:
fg = 'red'
name = parse_test_name(test['name'])
echo_style(
'{} {}'.format(name, test['outcome'].upper()),
no_color,
fg=fg
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'echo_verbose_results'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'no_color'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '42', '48']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '23', 'type': 'generator_expression', 'children': ['24', '31']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'{}: {}'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '31', 'type': 'for_in_clause', 'children': ['32', '35']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'info'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'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': 'click'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'for_statement', 'children': ['49', '50', '53']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'tests'"}; {'id': '53', 'type': 'block', 'children': ['54', '82', '91']}; {'id': '54', 'type': 'if_statement', 'children': ['55', '60', '65', '76']}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '59'], 'value': '=='}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'outcome'"}; {'id': '59', 'type': 'string', 'children': [], 'value': "'passed'"}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'green'"}; {'id': '65', 'type': 'elif_clause', 'children': ['66', '71']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '70'], 'value': '=='}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'outcome'"}; {'id': '70', 'type': 'string', 'children': [], 'value': "'skipped'"}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'yellow'"}; {'id': '76', 'type': 'else_clause', 'children': ['77']}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '81', 'type': 'string', 'children': [], 'value': "'red'"}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'parse_test_name'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'subscript', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '90', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'echo_style'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '108', '109']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'string', 'children': [], 'value': "'{} {}'"}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '101', 'type': 'call', 'children': ['102', '107']}; {'id': '102', 'type': 'attribute', 'children': ['103', '106']}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '105', 'type': 'string', 'children': [], 'value': "'outcome'"}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'no_color'}; {'id': '109', 'type': 'keyword_argument', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'fg'}
|
Print list of tests and result of each test.
|
def find_and_filter_sgf_files(base_dir, min_year=None, komi=None):
sgf_files = []
for dirpath, dirnames, filenames in os.walk(base_dir):
for filename in filenames:
if filename.endswith('.sgf'):
path = os.path.join(dirpath, filename)
sgf_files.append(path)
if min_year == komi == None:
print ("Found {} sgf_files".format(len(sgf_files)))
return sgf_files
f = filter_year_komi(min_year, komi)
filtered_sgf_files = [sgf for sgf in tqdm(sgf_files) if f(sgf)]
print("{} of {} .sgf files matched (min_year >= {}, komi = {})".format(
len(filtered_sgf_files), len(sgf_files), min_year, komi))
return filtered_sgf_files
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_and_filter_sgf_files'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'min_year'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'komi'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '16', '59', '80', '88', '104', '123']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'sgf_files'}; {'id': '15', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '21', '27']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'dirnames'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'for_statement', 'children': ['29', '30', '31']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '39']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'.sgf'"}; {'id': '39', 'type': 'block', 'children': ['40', '52']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'sgf_files'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '59', 'type': 'if_statement', 'children': ['60', '64']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62', '63'], 'value': '=='}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'min_year'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'komi'}; {'id': '63', 'type': 'None', 'children': []}; {'id': '64', 'type': 'block', 'children': ['65', '78']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'string', 'children': [], 'value': '"Found {} sgf_files"'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'sgf_files'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sgf_files'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'filter_year_komi'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'min_year'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'komi'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'filtered_sgf_files'}; {'id': '91', 'type': 'list_comprehension', 'children': ['92', '93', '99']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'sgf'}; {'id': '93', 'type': 'for_in_clause', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'sgf'}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'tqdm'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'sgf_files'}; {'id': '99', 'type': 'if_clause', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'sgf'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'string', 'children': [], 'value': '"{} of {} .sgf files matched (min_year >= {}, komi = {})"'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '117', '121', '122']}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'filtered_sgf_files'}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'sgf_files'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'min_year'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'komi'}; {'id': '123', 'type': 'return_statement', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'filtered_sgf_files'}
|
Finds all sgf files in base_dir with year >= min_year and komi
|
def overlays_at(self, key):
if isinstance(key, slice):
s, e, _ = key.indices(len(self.text))
else:
s = e = key
return [o for o in self.overlays if o.start in Rng(s, e)]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'overlays_at'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'block', 'children': ['7', '39']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '31']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'slice'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '20']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '31', 'type': 'else_clause', 'children': ['32']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'list_comprehension', 'children': ['41', '42', '47']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'overlays'}; {'id': '47', 'type': 'if_clause', 'children': ['48']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '52'], 'value': 'in'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'Rng'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'e'}
|
Key may be a slice or a point.
|
def AddATR(self, readernode, atr):
capchild = self.AppendItem(readernode, atr)
self.SetPyData(capchild, None)
self.SetItemImage(
capchild, self.cardimageindex, wx.TreeItemIcon_Normal)
self.SetItemImage(
capchild, self.cardimageindex, wx.TreeItemIcon_Expanded)
self.Expand(capchild)
return capchild
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'AddATR'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'readernode'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'atr'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '26', '39', '52', '59']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'capchild'}; {'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': 'AppendItem'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'readernode'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'atr'}; {'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': 'SetPyData'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'capchild'}; {'id': '25', 'type': 'None', 'children': []}; {'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': 'SetItemImage'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '36']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'capchild'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cardimageindex'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'wx'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'TreeItemIcon_Normal'}; {'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': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'SetItemImage'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46', '49']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'capchild'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cardimageindex'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'wx'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'TreeItemIcon_Expanded'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'Expand'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'capchild'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'capchild'}
|
Add an ATR to a reader node.
|
def _reorder_shape(input_shape, output=None):
if output is None:
return input_shape
return base.nested_map(output, lambda i: input_shape[i])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_reorder_shape'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'input_shape'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '16']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'input_shape'}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'nested_map'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '23', 'type': 'lambda', 'children': ['24', '26']}; {'id': '24', 'type': 'lambda_parameters', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'input_shape'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'i'}
|
Helper to determine the shape of reorder output.
|
def isportopen(host, port):
if not 1 <= int(port) <= 65535:
return False
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
out = sock.connect_ex((sanitize_host(host), int(port)))
return out
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'isportopen'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '33', '50']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '16']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11', '15'], 'value': '<='}; {'id': '10', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '65535'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'False', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'AF_INET'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'SOCK_STREAM'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'sock'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'connect_ex'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'tuple', 'children': ['42', '46']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'sanitize_host'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'out'}
|
Return status of a port
|
def flake(self, message):
self.stdout.write(str(message))
self.stdout.write('\n')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flake'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'\\n'"}
|
Print an error message to stdout.
|
def lset(self, name, index, value):
"Set ``position`` of list ``name`` to ``value``"
return self.execute_command('LSET', name, index, value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'block', 'children': ['9', '11']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"Set ``position`` of list ``name`` to ``value``"'}; {'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_command'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19', '20']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'LSET'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Set ``position`` of list ``name`` to ``value``
|
def fisher_vector_product(self, vector, kl_divergence_gradient, model):
assert not vector.requires_grad, "Vector must not propagate gradient"
dot_product = vector @ kl_divergence_gradient
double_gradient = torch.autograd.grad(dot_product, model.policy_parameters(), retain_graph=True)
fvp = p2v(x.contiguous() for x in double_gradient)
return fvp + vector * self.cg_damping
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fisher_vector_product'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kl_divergence_gradient'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '21', '40', '54']}; {'id': '9', 'type': 'assert_statement', 'children': ['10', '14']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'requires_grad'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"Vector must not propagate gradient"'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dot_product'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '20'], 'value': '@'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'kl_divergence_gradient'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'double_gradient'}; {'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': 'torch'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'autograd'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'grad'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '37']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'dot_product'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'policy_parameters'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'retain_graph'}; {'id': '39', 'type': 'True', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fvp'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'p2v'}; {'id': '45', 'type': 'generator_expression', 'children': ['46', '51']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'contiguous'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'for_in_clause', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'double_gradient'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '+'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'fvp'}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '*'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'cg_damping'}
|
Calculate product Hessian @ vector
|
def lookup_comment_by_wordpress_id(self, comment_id, comments):
for comment in comments:
if comment.wordpress_id == comment_id:
return comment
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lookup_comment_by_wordpress_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'comment_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'comments'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'comments'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': '=='}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'wordpress_id'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'comment_id'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'comment'}
|
Returns Django comment object with this wordpress id
|
def connect(self):
self.serial = serial.Serial(port=self.port, baudrate=self.baudrate, timeout=self.timeout)
self.alive = True
self.rxThread = threading.Thread(target=self._readLoop)
self.rxThread.daemon = True
self.rxThread.start()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '31', '37', '52', '60']}; {'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': 'serial'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'serial'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Serial'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '21', '26']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'baudrate'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'baudrate'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'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': 'alive'}; {'id': '36', 'type': 'True', 'children': []}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'rxThread'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'threading'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Thread'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_readLoop'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', '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': 'rxThread'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'daemon'}; {'id': '59', 'type': 'True', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'rxThread'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '67', 'type': 'argument_list', 'children': []}
|
Connects to the device and starts the read thread
|
def to_index(self, index_type, index_name, includes=None):
return IndexField(self.name, self.data_type, index_type, index_name, includes)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index_type'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'index_name'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'includes'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'IndexField'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18', '21', '22', '23']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'index_type'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'index_name'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'includes'}
|
Create an index field from this field
|
def _(pymux, variables):
" Go to previous active window. "
w = pymux.arrangement.get_previous_active_window()
if w:
pymux.arrangement.set_active_window(w)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pymux'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '" Go to previous active window. "'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pymux'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'arrangement'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_previous_active_window'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'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': 'pymux'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'arrangement'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'set_active_window'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'w'}
|
Go to previous active window.
|
def ExistingFileOrNone(fname):
if os.path.isfile(fname):
return fname
elif fname.lower() == 'none':
return None
else:
raise ValueError("%s must specify a valid file name or 'None'" % fname)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ExistingFileOrNone'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15', '18', '29']}; {'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': 'isfile'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '18', 'type': 'elif_clause', 'children': ['19', '26']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '25'], 'value': '=='}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'string', 'children': [], 'value': "'none'"}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'else_clause', 'children': ['30']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'raise_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '%'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"%s must specify a valid file name or \'None\'"'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'fname'}
|
Like `Existingfile`, but if `fname` is string "None" then return `None`.
|
def load(config, opt):
ctx = Context(opt)
seed_map = py_resources()
seed_keys = sorted(set([m[0] for m in seed_map]), key=resource_sort)
for config_key in seed_keys:
if config_key not in config:
continue
for resource_config in config[config_key]:
mod = find_model(config_key, resource_config, seed_map)
if not mod:
LOG.warning("unable to find mod for %s", resource_config)
continue
ctx.add(mod(resource_config, opt))
for config_key in config.keys():
if config_key != 'pgp_keys' and \
config_key not in seed_keys:
LOG.warning("missing model for %s", config_key)
return filtered_context(ctx)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '20', '39', '88', '114']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Context'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'seed_map'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'py_resources'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'seed_keys'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '36']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'list_comprehension', 'children': ['30', '33']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'for_in_clause', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'seed_map'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'resource_sort'}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'seed_keys'}; {'id': '42', 'type': 'block', 'children': ['43', '49']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '47']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'not in'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'continue_statement', 'children': []}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '54']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'resource_config'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '54', 'type': 'block', 'children': ['55', '64', '77']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'mod'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'find_model'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'resource_config'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'seed_map'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '67']}; {'id': '65', 'type': 'not_operator', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'mod'}; {'id': '67', 'type': 'block', 'children': ['68', '76']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"unable to find mod for %s"'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'resource_config'}; {'id': '76', 'type': 'continue_statement', 'children': []}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'mod'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'resource_config'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '88', 'type': 'for_statement', 'children': ['89', '90', '95']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '94', 'type': 'argument_list', 'children': []}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'if_statement', 'children': ['97', '105']}; {'id': '97', 'type': 'boolean_operator', 'children': ['98', '101', '102'], 'value': 'and'}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': '!='}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '100', 'type': 'string', 'children': [], 'value': "'pgp_keys'"}; {'id': '101', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': 'not in'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'seed_keys'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '111', 'type': 'argument_list', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': '"missing model for %s"'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'config_key'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'filtered_context'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'ctx'}
|
Loads and returns a full context object based on the Secretfile
|
def _assert_expandable(repl, use_format=False):
if isinstance(repl, ReplaceTemplate):
if repl.use_format != use_format:
if use_format:
raise ValueError("Replace not compiled as a format replace")
else:
raise ValueError("Replace should not be compiled as a format replace!")
elif not isinstance(repl, (str, bytes)):
raise TypeError("Expected string, buffer, or compiled replace!")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_assert_expandable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'repl'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'use_format'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15', '38']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'repl'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ReplaceTemplate'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '22']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '21'], 'value': '!='}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'repl'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'use_format'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'use_format'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '25', '31']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'use_format'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"Replace not compiled as a format replace"'}; {'id': '31', 'type': 'else_clause', 'children': ['32']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'raise_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"Replace should not be compiled as a format replace!"'}; {'id': '38', 'type': 'elif_clause', 'children': ['39', '47']}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'repl'}; {'id': '44', 'type': 'tuple', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'raise_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"Expected string, buffer, or compiled replace!"'}
|
Check if replace template is expandable.
|
def transform(self, m):
if len(m) != 6:
raise ValueError("bad sequ. length")
self.ul *= m
self.ur *= m
self.ll *= m
self.lr *= m
return self
|
{'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': 'm'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '26', '32', '38', '44']}; {'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': 'm'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"bad sequ. length"'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'augmented_assignment', 'children': ['22', '25'], 'value': '*='}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ul'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'augmented_assignment', 'children': ['28', '31'], 'value': '*='}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ur'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'augmented_assignment', 'children': ['34', '37'], 'value': '*='}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'll'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'augmented_assignment', 'children': ['40', '43'], 'value': '*='}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'lr'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}
|
Replace quad by its transformation with matrix m.
|
def resample_single_nifti(input_nifti):
input_image = nibabel.load(input_nifti)
output_image = resample_nifti_images([input_image])
output_image.to_filename(input_nifti)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resample_single_nifti'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'input_nifti'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'input_image'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'nibabel'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'input_nifti'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'output_image'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'resample_nifti_images'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'list', 'children': ['22'], 'value': '[input_image]'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'input_image'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'output_image'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'to_filename'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'input_nifti'}
|
Resample a gantry tilted image in place
|
def pex_hash(cls, d):
names = sorted(f for f in cls._iter_files(d) if not (f.endswith('.pyc') or f.startswith('.')))
def stream_factory(name):
return open(os.path.join(d, name), 'rb')
return cls._compute_hash(names, stream_factory)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pex_hash'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '6', 'type': 'block', 'children': ['7', '38', '57']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '12', 'type': 'generator_expression', 'children': ['13', '14', '22']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '14', 'type': 'for_in_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_iter_files'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '22', 'type': 'if_clause', 'children': ['23']}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': '()', 'children': ['25']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '32'], 'value': 'or'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'.pyc'"}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '38', 'type': 'function_definition', 'children': ['39', '40', '42']}; {'id': '39', 'type': 'function_name', 'children': [], 'value': 'stream_factory'}; {'id': '40', 'type': 'parameters', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '56']}; {'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': 'os'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': '_compute_hash'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'stream_factory'}
|
Return a reproducible hash of the contents of a directory.
|
def _call(self, coeffs):
if self.impl == 'pywt':
coeffs = pywt.unravel_coeffs(coeffs,
coeff_slices=self._coeff_slices,
coeff_shapes=self._coeff_shapes,
output_format='wavedecn')
recon = pywt.waverecn(
coeffs, wavelet=self.pywt_wavelet, mode=self.pywt_pad_mode,
axes=self.axes)
recon_shape = self.range.shape
if recon.shape != recon_shape:
recon_slc = []
for i, (n_recon, n_intended) in enumerate(zip(recon.shape,
recon_shape)):
if n_recon == n_intended + 1:
recon_slc.append(slice(-1))
elif n_recon == n_intended:
recon_slc.append(slice(None))
else:
raise ValueError(
'in axis {}: expected size {} or {} in '
'`recon_shape`, got {}'
''.format(i, n_recon - 1, n_recon,
n_intended))
recon = recon[tuple(recon_slc)]
return recon
else:
raise RuntimeError("bad `impl` '{}'".format(self.impl))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_call'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'coeffs'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '160']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': '=='}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'impl'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'pywt'"}; {'id': '13', 'type': 'block', 'children': ['14', '36', '60', '68', '158']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'coeffs'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pywt'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'unravel_coeffs'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '28', '33']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'coeffs'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'coeff_slices'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_coeff_slices'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'coeff_shapes'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_coeff_shapes'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'output_format'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'wavedecn'"}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'recon'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'pywt'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'waverecn'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45', '50', '55']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'coeffs'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'wavelet'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pywt_wavelet'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'pywt_pad_mode'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'recon_shape'}; {'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': 'range'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '68', 'type': 'if_statement', 'children': ['69', '74']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '73'], 'value': '!='}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'recon'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'recon_shape'}; {'id': '74', 'type': 'block', 'children': ['75', '79', '149']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'recon_slc'}; {'id': '78', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '79', 'type': 'for_statement', 'children': ['80', '85', '95']}; {'id': '80', 'type': 'pattern_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '82', 'type': 'tuple_pattern', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'n_recon'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'n_intended'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'recon'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'recon_shape'}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'if_statement', 'children': ['97', '102', '114', '129']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': '=='}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'n_recon'}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '+'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'n_intended'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'recon_slc'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'slice'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'unary_operator', 'children': ['113'], 'value': '-'}; {'id': '113', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '114', 'type': 'elif_clause', 'children': ['115', '118']}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': '=='}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'n_recon'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'n_intended'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'recon_slc'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'slice'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'None', 'children': []}; {'id': '129', 'type': 'else_clause', 'children': ['130']}; {'id': '130', 'type': 'block', 'children': ['131']}; {'id': '131', 'type': 'raise_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '142']}; {'id': '136', 'type': 'attribute', 'children': ['137', '141']}; {'id': '137', 'type': 'concatenated_string', 'children': ['138', '139', '140']}; {'id': '138', 'type': 'string', 'children': [], 'value': "'in axis {}: expected size {} or {} in '"}; {'id': '139', 'type': 'string', 'children': [], 'value': "'`recon_shape`, got {}'"}; {'id': '140', 'type': 'string', 'children': [], 'value': "''"}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '142', 'type': 'argument_list', 'children': ['143', '144', '147', '148']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '144', 'type': 'binary_operator', 'children': ['145', '146'], 'value': '-'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'n_recon'}; {'id': '146', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'n_recon'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'n_intended'}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'recon'}; {'id': '152', 'type': 'subscript', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'recon'}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'recon_slc'}; {'id': '158', 'type': 'return_statement', 'children': ['159']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'recon'}; {'id': '160', 'type': 'else_clause', 'children': ['161']}; {'id': '161', 'type': 'block', 'children': ['162']}; {'id': '162', 'type': 'raise_statement', 'children': ['163']}; {'id': '163', 'type': 'call', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'call', 'children': ['167', '170']}; {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'string', 'children': [], 'value': '"bad `impl` \'{}\'"'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}; {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'impl'}
|
Return the inverse wavelet transform of ``coeffs``.
|
def __get_yubico_users(username):
user = {}
try:
if __opts__['yubico_users'].get(username, None):
(user['id'], user['key']) = list(__opts__['yubico_users'][username].values())
else:
return None
except KeyError:
return None
return user
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_yubico_users'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '53']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'try_statement', 'children': ['11', '48']}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '22', '44']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'yubico_users'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '32']}; {'id': '25', 'type': 'tuple_pattern', 'children': ['26', '29']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'key'"}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '43']}; {'id': '36', 'type': 'attribute', 'children': ['37', '42']}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'yubico_users'"}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'None', 'children': []}; {'id': '48', 'type': 'except_clause', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'user'}
|
Grab the YubiKey Client ID & Secret Key
|
def in_lamp_reach(p):
v1 = XYPoint(Lime.x - Red.x, Lime.y - Red.y)
v2 = XYPoint(Blue.x - Red.x, Blue.y - Red.y)
q = XYPoint(p.x - Red.x, p.y - Red.y)
s = cross_product(q, v2) / cross_product(v1, v2)
t = cross_product(v1, q) / cross_product(v1, v2)
return (s >= 0.0) and (t >= 0.0) and (s + t <= 1.0)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'in_lamp_reach'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '5', 'type': 'block', 'children': ['6', '26', '46', '66', '80', '94']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'v1'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'XYPoint'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '19']}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '16'], 'value': '-'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Lime'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Red'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '23'], 'value': '-'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Lime'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Red'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'v2'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'XYPoint'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '39']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '36'], 'value': '-'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'Blue'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Red'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '43'], 'value': '-'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Blue'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'Red'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'XYPoint'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '59']}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '56'], 'value': '-'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'Red'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '63'], 'value': '-'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'Red'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '69', 'type': 'binary_operator', 'children': ['70', '75'], 'value': '/'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'cross_product'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'v2'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'cross_product'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'v1'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'v2'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '89'], 'value': '/'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'cross_product'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'v1'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'cross_product'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'v1'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'v2'}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'boolean_operator', 'children': ['96', '105'], 'value': 'and'}; {'id': '96', 'type': 'boolean_operator', 'children': ['97', '101'], 'value': 'and'}; {'id': '97', 'type': '()', 'children': ['98']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': '>='}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '100', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '101', 'type': '()', 'children': ['102']}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': '>='}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '104', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '105', 'type': '()', 'children': ['106']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '110'], 'value': '<='}; {'id': '107', 'type': 'binary_operator', 'children': ['108', '109'], 'value': '+'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '110', 'type': 'float', 'children': [], 'value': '1.0'}
|
Check if the provided XYPoint can be recreated by a Hue lamp.
|
def chunks(l,n):
return [l[x:x+n] for x in range(0, len(l), n)];
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chunks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'list_comprehension', 'children': ['9', '17']}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '11', 'type': 'slice', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '13', 'type': 'colon', 'children': []}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '16'], 'value': '+'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '17', 'type': 'for_in_clause', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '27']}; {'id': '22', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'n'}
|
chunk l in n sized bits
|
def infer_attribute(self, context=None):
for owner in self.expr.infer(context):
if owner is util.Uninferable:
yield owner
continue
if context and context.boundnode:
if isinstance(owner, bases.Instance) and isinstance(
context.boundnode, bases.Instance
):
try:
if helpers.is_subtype(
helpers.object_type(context.boundnode),
helpers.object_type(owner),
):
owner = context.boundnode
except exceptions._NonDeducibleTypeHierarchy:
pass
try:
context.boundnode = owner
yield from owner.igetattr(self.attrname, context)
context.boundnode = None
except (exceptions.AttributeInferenceError, exceptions.InferenceError):
context.boundnode = None
except AttributeError:
context.boundnode = None
return dict(node=self, context=context)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'infer_attribute'}; {'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': 'context'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '141']}; {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '19']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'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': 'expr'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'infer'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '19', 'type': 'block', 'children': ['20', '31', '92']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '26']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': 'is'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Uninferable'}; {'id': '26', 'type': 'block', 'children': ['27', '30']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'yield', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '30', 'type': 'continue_statement', 'children': []}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37']}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '34'], 'value': 'and'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'if_statement', 'children': ['39', '56']}; {'id': '39', 'type': 'boolean_operator', 'children': ['40', '47'], 'value': 'and'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'bases'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Instance'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'bases'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'Instance'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'try_statement', 'children': ['58', '86']}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'if_statement', 'children': ['60', '79']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'helpers'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'is_subtype'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '73']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'helpers'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'object_type'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'helpers'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'object_type'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '86', 'type': 'except_clause', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_NonDeducibleTypeHierarchy'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'pass_statement', 'children': []}; {'id': '92', 'type': 'try_statement', 'children': ['93', '117', '132']}; {'id': '93', 'type': 'block', 'children': ['94', '100', '111']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'yield', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'igetattr'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'attrname'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '116', 'type': 'None', 'children': []}; {'id': '117', 'type': 'except_clause', 'children': ['118', '125']}; {'id': '118', 'type': 'tuple', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'AttributeInferenceError'}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'InferenceError'}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '131', 'type': 'None', 'children': []}; {'id': '132', 'type': 'except_clause', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '134', 'type': 'block', 'children': ['135']}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'boundnode'}; {'id': '140', 'type': 'None', 'children': []}; {'id': '141', 'type': 'return_statement', 'children': ['142']}; {'id': '142', 'type': 'call', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '144', 'type': 'argument_list', 'children': ['145', '148']}; {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '148', 'type': 'keyword_argument', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'context'}
|
infer an Attribute node by using getattr on the associated object
|
def _draw_footer(self):
n_rows, n_cols = self.term.stdscr.getmaxyx()
window = self.term.stdscr.derwin(1, n_cols, self._row, 0)
window.erase()
window.bkgd(str(' '), self.term.attr('HelpBar'))
text = self.FOOTER.strip()
self.term.add_line(window, text, 0, 0)
self._row += 1
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_draw_footer'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '38', '44', '62', '72', '84']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'n_rows'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'n_cols'}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'stdscr'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'getmaxyx'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'window'}; {'id': '23', 'type': 'call', 'children': ['24', '31']}; {'id': '24', 'type': 'attribute', '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': 'term'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'stdscr'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'derwin'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '34', '37']}; {'id': '32', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'n_cols'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_row'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'window'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'erase'}; {'id': '43', 'type': 'argument_list', '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': 'window'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'bkgd'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '54']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'HelpBar'"}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'FOOTER'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', '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': 'term'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'add_line'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81', '82', '83']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'window'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'augmented_assignment', 'children': ['86', '89'], 'value': '+='}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_row'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '1'}
|
Draw the key binds help bar at the bottom of the screen
|
def _idx_to_bits(self, i):
bits = bin(i)[2:].zfill(self.nb_hyperplanes)
return [-1.0 if b == "0" else 1.0 for b in bits]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_idx_to_bits'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'bits'}; {'id': '10', 'type': 'call', 'children': ['11', '21']}; {'id': '11', 'type': 'attribute', 'children': ['12', '20']}; {'id': '12', 'type': 'subscript', 'children': ['13', '17']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '17', 'type': 'slice', 'children': ['18', '19']}; {'id': '18', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '19', 'type': 'colon', 'children': []}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'zfill'}; {'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': 'nb_hyperplanes'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'list_comprehension', 'children': ['27', '34']}; {'id': '27', 'type': 'conditional_expression', 'children': ['28', '30', '33'], 'value': 'if'}; {'id': '28', 'type': 'unary_operator', 'children': ['29'], 'value': '-'}; {'id': '29', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '=='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"0"'}; {'id': '33', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '34', 'type': 'for_in_clause', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bits'}
|
Convert an group index to its bit representation.
|
def se(self):
global _complained_se
if not _complained_se:
_complained_se = True
l.critical("The name state.se is deprecated; please use state.solver.")
return self.get_plugin('solver')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'se'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '23']}; {'id': '6', 'type': 'global_statement', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': '_complained_se'}; {'id': '8', 'type': 'if_statement', 'children': ['9', '11']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_complained_se'}; {'id': '11', 'type': 'block', 'children': ['12', '16']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_complained_se'}; {'id': '15', 'type': 'True', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'critical'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"The name state.se is deprecated; please use state.solver."'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get_plugin'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'solver'"}
|
Deprecated alias for `solver`
|
def U_ij(q_vars: List[fl.Var], mass: np.ndarray, i: int, j: int):
assert len(q_vars) == 3 * len(mass)
mi = mass[i]
mj = mass[j]
U = -(G * mi * mj) / flux_r(q_vars, i, j)
return U
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'U_ij'}; {'id': '3', 'type': 'parameters', 'children': ['4', '14', '20', '24']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'q_vars'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'fl'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Var'}; {'id': '14', 'type': 'typed_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '20', 'type': 'typed_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '22', 'type': 'type', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '24', 'type': 'typed_parameter', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '26', 'type': 'type', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '28', 'type': 'block', 'children': ['29', '41', '47', '53', '70']}; {'id': '29', 'type': 'assert_statement', 'children': ['30']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '35'], 'value': '=='}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'q_vars'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '*'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '3'}; {'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': 'mass'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'mi'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'mj'}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'U'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '64'], 'value': '/'}; {'id': '57', 'type': 'unary_operator', 'children': ['58'], 'value': '-'}; {'id': '58', 'type': '()', 'children': ['59']}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '63'], 'value': '*'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '*'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'mi'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'mj'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'flux_r'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68', '69']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'q_vars'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'U'}
|
Make Fluxion with the gratiational potential energy beween body i and j
|
def load(self):
if not op.exists(self.path):
logger.debug("The GUI state file `%s` doesn't exist.", self.path)
return
assert op.exists(self.path)
logger.debug("Load the GUI state from `%s`.", self.path)
self.update(_bunchify(_load_json(self.path)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '28', '37', '47']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'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': 'op'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'block', 'children': ['17', '27']}; {'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': 'logger'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"The GUI state file `%s` doesn\'t exist."'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'return_statement', 'children': []}; {'id': '28', 'type': 'assert_statement', 'children': ['29']}; {'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': 'exists'}; {'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': 'path'}; {'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': 'logger'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"Load the GUI state from `%s`."'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_bunchify'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_load_json'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'path'}
|
Load the state from the JSON file in the config dir.
|
def cache_makedirs(self, subdir=None):
if subdir is not None:
dirname = self.cache_path
if subdir:
dirname = os.path.join(dirname, subdir)
else:
dirname = os.path.dirname(self.cache_path)
os.makedirs(dirname, exist_ok=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cache_makedirs'}; {'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': 'subdir'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '50']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13', '35']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is not'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'subdir'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '20']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'cache_path'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'subdir'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'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': 'os'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'subdir'}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cache_path'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'exist_ok'}; {'id': '59', 'type': 'True', 'children': []}
|
Make necessary directories to hold cache value
|
def check_is_a_mapping(var, allow_none=False):
if not is_a_mapping(var, allow_none=allow_none):
raise TypeError("var must be a dict, however type(var) is {}"
.format(type(var)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_is_a_mapping'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'allow_none'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '18']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'is_a_mapping'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'allow_none'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'allow_none'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'raise_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"var must be a dict, however type(var) is {}"'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'var'}
|
Calls is_a_mapping and raises a type error if the check fails.
|
def echo(
message=None, file=None, nl=True, err=False, color=None, carriage_return=False
):
message = message or ""
if carriage_return and nl:
click_echo(message + "\r\n", file, False, err, color)
elif carriage_return and not nl:
click_echo(message + "\r", file, False, err, color)
else:
click_echo(message, file, nl, err, color)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'echo'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '12', 'type': 'True', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '15', 'type': 'False', 'children': []}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'carriage_return'}; {'id': '21', 'type': 'False', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23', '29']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '28'], 'value': 'or'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '28', 'type': 'string', 'children': [], 'value': '""'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '33', '45', '62']}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '32'], 'value': 'and'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'carriage_return'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'click_echo'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '41', '42', '43', '44']}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '+'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"\\r\\n"'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '42', 'type': 'False', 'children': []}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '45', 'type': 'elif_clause', 'children': ['46', '50']}; {'id': '46', 'type': 'boolean_operator', 'children': ['47', '48'], 'value': 'and'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'carriage_return'}; {'id': '48', 'type': 'not_operator', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'click_echo'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '58', '59', '60', '61']}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '+'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"\\r"'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '59', 'type': 'False', 'children': []}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '62', 'type': 'else_clause', 'children': ['63']}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'click_echo'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '70', '71', '72']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'nl'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'color'}
|
Patched click echo function.
|
def add_thread(self, checker, end_callback, source_code, parent):
parent_id = id(parent)
thread = AnalysisThread(self, checker, source_code)
self.end_callbacks[id(thread)] = end_callback
self.pending_threads.append((thread, parent_id))
logger.debug("Added thread %r to queue" % thread)
QTimer.singleShot(50, self.update_queue)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_thread'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'checker'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'end_callback'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'source_code'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '9', 'type': 'block', 'children': ['10', '17', '26', '37', '48', '57']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'parent_id'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'thread'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'AnalysisThread'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'checker'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'source_code'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '36']}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'end_callbacks'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'thread'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'end_callback'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pending_threads'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'tuple', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'thread'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'parent_id'}; {'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': 'logger'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '%'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"Added thread %r to queue"'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'thread'}; {'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': 'QTimer'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'singleShot'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'integer', 'children': [], 'value': '50'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'update_queue'}
|
Add thread to queue
|
def numberarray(x, shape):
try:
iter(x)
except TypeError:
return numpy.ones(shape) * x
else:
return x
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'numberarray'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '14', '26']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '14', 'type': 'except_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '25'], 'value': '*'}; {'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': 'ones'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'x'}
|
Return x if it is an array or create an array and fill it with x.
|
def _configure_cdn(self):
ident = self.identity
cdn_svc = ident.services.get("object_cdn")
if cdn_svc:
ep = cdn_svc.endpoints.get(self.region_name)
if ep:
self.cdn_management_url = ep.public_url
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_configure_cdn'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ident'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'cdn_svc'}; {'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': 'ident'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'services'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"object_cdn"'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cdn_svc'}; {'id': '25', 'type': 'block', 'children': ['26', '39']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'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': 'cdn_svc'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'endpoints'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'region_name'}; {'id': '39', 'type': 'if_statement', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'cdn_management_url'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'public_url'}
|
Initialize CDN-related endpoints, if available.
|
def parse_action(action, parsed):
if action == "list":
list_env()
elif action == "new":
new_env(parsed.environment)
elif action == "remove":
remove_env(parsed.environment)
elif action == "show":
show_env(parsed.environment)
elif action == "start":
start_env(parsed.environment, parsed.path)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_action'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11', '16', '28', '40', '52']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '=='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"list"'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'list_env'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'elif_clause', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': '=='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"new"'}; {'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': 'new_env'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '28', 'type': 'elif_clause', 'children': ['29', '32']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"remove"'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'remove_env'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '40', 'type': 'elif_clause', 'children': ['41', '44']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': '=='}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"show"'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'show_env'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '52', 'type': 'elif_clause', 'children': ['53', '56']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': '=='}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"start"'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'start_env'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'path'}
|
Parse the action to execute.
|
async def sentinel_monitor(self, name, ip, port, quorum):
"Add a new master to Sentinel to be monitored"
return await self.execute_command('SENTINEL MONITOR', name, ip, port, quorum)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sentinel_monitor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'quorum'}; {'id': '9', 'type': 'block', 'children': ['10', '12']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"Add a new master to Sentinel to be monitored"'}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'await', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'execute_command'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '21', '22', '23']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'SENTINEL MONITOR'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'quorum'}
|
Add a new master to Sentinel to be monitored
|
def _setup_bar(self):
bar = u""
items_cnt = len(PROGRESS_BAR_ITEMS)
bar_val = float(self._time_left) / self._section_time * self.num_progress_bars
while bar_val > 0:
selector = int(bar_val * items_cnt)
selector = min(selector, items_cnt - 1)
bar += PROGRESS_BAR_ITEMS[selector]
bar_val -= 1
bar = bar.ljust(self.num_progress_bars)
return bar
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setup_bar'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '17', '34', '68', '79']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bar'}; {'id': '9', 'type': 'string', 'children': [], 'value': 'u""'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'items_cnt'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'PROGRESS_BAR_ITEMS'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'bar_val'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '31'], 'value': '*'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '28'], 'value': '/'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_time_left'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_section_time'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'num_progress_bars'}; {'id': '34', 'type': 'while_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': '>'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bar_val'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'block', 'children': ['39', '48', '58', '64']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '*'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'bar_val'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'items_cnt'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'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': 'selector'}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '-'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'items_cnt'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'augmented_assignment', 'children': ['60', '61'], 'value': '+='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'bar'}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'PROGRESS_BAR_ITEMS'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'augmented_assignment', 'children': ['66', '67'], 'value': '-='}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'bar_val'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'bar'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'bar'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ljust'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'num_progress_bars'}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'bar'}
|
Setup the process bar.
|
def chain(*args):
has_iter = partial(hasattr, name='__iter__')
if len(args) == 1 and hasattr(args[0], '__iter__'):
args = args[0]
for arg in args:
if hasattr(arg, '__iter__'):
for i in arg:
yield i
else:
yield arg
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chain'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '39']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'has_iter'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'__iter__'"}; {'id': '17', 'type': 'if_statement', 'children': ['18', '32']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '25'], 'value': 'and'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '24'], 'value': '=='}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'__iter__'"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '49', '57']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'__iter__'"}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'for_statement', 'children': ['51', '52', '53']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'yield', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '57', 'type': 'else_clause', 'children': ['58']}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'yield', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'arg'}
|
itertools.chain, just better
|
def convert_to_nested_dict(dotted_dict):
nested_dict = {}
for k, v in iterate_flattened(dotted_dict):
set_by_dotted_path(nested_dict, k, v)
return nested_dict
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_to_nested_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dotted_dict'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '26']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'nested_dict'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '14', '18']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'iterate_flattened'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dotted_dict'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'set_by_dotted_path'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'nested_dict'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'nested_dict'}
|
Convert a dict with dotted path keys to corresponding nested dict.
|
def add_raw_code(self, string_or_list):
if _is_string(string_or_list):
self._GMSH_CODE.append(string_or_list)
else:
assert isinstance(string_or_list, list)
for string in string_or_list:
self._GMSH_CODE.append(string)
return
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_raw_code'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'string_or_list'}; {'id': '6', 'type': 'block', 'children': ['7', '43']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '12', '22']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_is_string'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'string_or_list'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_GMSH_CODE'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'string_or_list'}; {'id': '22', 'type': 'else_clause', 'children': ['23']}; {'id': '23', 'type': 'block', 'children': ['24', '30']}; {'id': '24', 'type': 'assert_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'string_or_list'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'string_or_list'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'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': '_GMSH_CODE'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '43', 'type': 'return_statement', 'children': []}
|
Add raw Gmsh code.
|
def by_value(self, value, default=None):
try:
return [k for k, v in self.items() if v == value][0]
except IndexError:
if default is not None:
return default
raise ValueError('%s' % value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'by_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': 'default'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'try_statement', 'children': ['11', '30']}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'subscript', 'children': ['14', '29']}; {'id': '14', 'type': 'list_comprehension', 'children': ['15', '16', '25']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '16', 'type': 'for_in_clause', 'children': ['17', '20']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'v'}; {'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': 'items'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'if_clause', 'children': ['26']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': '=='}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'except_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '32', 'type': 'block', 'children': ['33', '40']}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'is not'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '40', 'type': 'raise_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '%'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'%s'"}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Returns the key for the given value
|
def parse_ini_file(self, path):
cfgobj = ConfigObj(path, list_values=False)
def extract_section(namespace, d):
cfg = {}
for key, val in d.items():
if isinstance(d[key], dict):
cfg.update(extract_section(namespace + [key], d[key]))
else:
cfg['_'.join(namespace + [key]).upper()] = val
return cfg
return extract_section([], cfgobj.dict())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_ini_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '84']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'cfgobj'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ConfigObj'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'list_values'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'function_definition', 'children': ['18', '19', '22']}; {'id': '18', 'type': 'function_name', 'children': [], 'value': 'extract_section'}; {'id': '19', 'type': 'parameters', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '22', 'type': 'block', 'children': ['23', '27', '82']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '26', 'type': 'dictionary', 'children': []}; {'id': '27', 'type': 'for_statement', 'children': ['28', '31', '36']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '45', '62']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'extract_section'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '59']}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '+'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '57', 'type': 'list', 'children': ['58'], 'value': '[key]'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '62', 'type': 'else_clause', 'children': ['63']}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '81']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '68', 'type': 'call', 'children': ['69', '80']}; {'id': '69', 'type': 'attribute', 'children': ['70', '79']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '+'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '77', 'type': 'list', 'children': ['78'], 'value': '[key]'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'extract_section'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'cfgobj'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '93', 'type': 'argument_list', 'children': []}
|
Parse ini file at ``path`` and return dict.
|
def live_weather(self, live_weather):
summary = live_weather['currently']['summary']
self.summary(summary)
click.echo()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'live_weather'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'live_weather'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '22']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '10', 'type': 'subscript', 'children': ['11', '14']}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'live_weather'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'currently'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "'summary'"}; {'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': 'summary'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'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': 'click'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '27', 'type': 'argument_list', 'children': []}
|
Prints the live weather in a pretty format
|
def normalize(self, address, **kwargs):
addresses = super(AddressType, self).normalize(address, **kwargs)
return addresses
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '24']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'addresses'}; {'id': '12', 'type': 'call', 'children': ['13', '20']}; {'id': '13', 'type': 'attribute', 'children': ['14', '19']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'AddressType'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'normalize'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '22', 'type': 'dictionary_splat', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'addresses'}
|
Make the address more compareable.
|
def _parse_references(xml):
references = []
ref_finder = HTMLReferenceFinder(xml)
for elm, uri_attr in ref_finder:
type_ = _discover_uri_type(elm.get(uri_attr))
references.append(Reference(elm, type_, uri_attr))
return references
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_references'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'xml'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '17', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'references'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ref_finder'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'HTMLReferenceFinder'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'xml'}; {'id': '17', 'type': 'for_statement', 'children': ['18', '21', '22']}; {'id': '18', 'type': 'pattern_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'elm'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'uri_attr'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ref_finder'}; {'id': '22', 'type': 'block', 'children': ['23', '35']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_discover_uri_type'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'elm'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'uri_attr'}; {'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': 'references'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Reference'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45', '46']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'elm'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'type_'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'uri_attr'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'references'}
|
Parse the references to ``Reference`` instances.
|
def update_flavor(self, flavor, body):
return self.put(self.flavor_path % (flavor), body=body)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_flavor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'flavor'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_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': 'put'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '20']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '18'], 'value': '%'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'flavor_path'}; {'id': '18', 'type': '()', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'flavor'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'body'}
|
Update a Neutron service flavor.
|
def teardown_socket(s):
try:
s.shutdown(socket.SHUT_WR)
except socket.error:
pass
finally:
s.close()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'teardown_socket'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '17', '23']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'shutdown'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'SHUT_WR'}; {'id': '17', 'type': 'except_clause', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'pass_statement', 'children': []}; {'id': '23', 'type': 'finally_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '30', 'type': 'argument_list', 'children': []}
|
Shuts down and closes a socket.
|
def run_etime(self):
if self.start_datetime is None or self.end_datetime is None:
return None
return self.end_datetime - self.start_datetime
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_etime'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '18']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '13'], 'value': 'or'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'start_datetime'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': 'is'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'end_datetime'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '26'], 'value': '-'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'end_datetime'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'start_datetime'}
|
Wall-time of the run as `timedelta` object.
|
def get(self, timeout=None):
self.wait(timeout)
if isinstance(self._result, Exception):
raise self._result
return self._result
|
{'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': 'timeout'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '16', '29']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'wait'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '24']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_result'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_result'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_result'}
|
Return the result or raise the error the function has produced
|
def add_object(self, obj):
state = self.state
if not obj.layer in state.layers:
state.layers[obj.layer] = {}
state.layers[obj.layer][obj.key] = obj
state.need_redraw = True
if (not self.legend_checkbox_menuitem_added and
isinstance(obj, SlipFlightModeLegend)):
self.add_legend_checkbox_menuitem()
self.legend_checkbox_menuitem_added = True
self.SetMenuBar(self.menu.wx_menu())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_object'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '33', '47', '53']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '13', 'type': 'if_statement', 'children': ['14', '22']}; {'id': '14', 'type': 'not_operator', 'children': ['15']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '19'], 'value': 'in'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'layer'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'layers'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '32']}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'layers'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'layer'}; {'id': '32', 'type': 'dictionary', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '46']}; {'id': '35', 'type': 'subscript', 'children': ['36', '43']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'layers'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'layer'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'need_redraw'}; {'id': '52', 'type': 'True', 'children': []}; {'id': '53', 'type': 'if_statement', 'children': ['54', '65']}; {'id': '54', 'type': '()', 'children': ['55']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '60'], 'value': 'and'}; {'id': '56', 'type': 'not_operator', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'legend_checkbox_menuitem_added'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'SlipFlightModeLegend'}; {'id': '65', 'type': 'block', 'children': ['66', '72', '78']}; {'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': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'add_legend_checkbox_menuitem'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'legend_checkbox_menuitem_added'}; {'id': '77', 'type': 'True', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'SetMenuBar'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '90']}; {'id': '85', 'type': 'attribute', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'menu'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'wx_menu'}; {'id': '90', 'type': 'argument_list', 'children': []}
|
add an object to a layer
|
def page_sequence(n_sheets: int, one_based: bool = True) -> List[int]:
n_pages = calc_n_virtual_pages(n_sheets)
assert n_pages % 4 == 0
half_n_pages = n_pages // 2
firsthalf = list(range(half_n_pages))
secondhalf = list(reversed(range(half_n_pages, n_pages)))
sequence = []
top = True
for left, right in zip(secondhalf, firsthalf):
if not top:
left, right = right, left
sequence += [left, right]
top = not top
if one_based:
sequence = [x + 1 for x in sequence]
log.debug("{} sheets => page sequence {!r}", n_sheets, sequence)
return sequence
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'page_sequence'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'n_sheets'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '8', 'type': 'typed_default_parameter', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'one_based'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '12', 'type': 'True', 'children': []}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'generic_type', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '16', 'type': 'type_parameter', 'children': ['17']}; {'id': '17', 'type': 'type', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '19', 'type': 'block', 'children': ['20', '27', '33', '39', '49', '63', '67', '71', '104', '117', '126']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'n_pages'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'calc_n_virtual_pages'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'n_sheets'}; {'id': '27', 'type': 'assert_statement', 'children': ['28']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': '=='}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '%'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'n_pages'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'half_n_pages'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '//'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'n_pages'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'firsthalf'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'half_n_pages'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'secondhalf'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'half_n_pages'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'n_pages'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '66', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '70', 'type': 'True', 'children': []}; {'id': '71', 'type': 'for_statement', 'children': ['72', '75', '80']}; {'id': '72', 'type': 'pattern_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'secondhalf'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'firsthalf'}; {'id': '80', 'type': 'block', 'children': ['81', '93', '99']}; {'id': '81', 'type': 'if_statement', 'children': ['82', '84']}; {'id': '82', 'type': 'not_operator', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '90']}; {'id': '87', 'type': 'pattern_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '90', 'type': 'expression_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'augmented_assignment', 'children': ['95', '96'], 'value': '+='}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '96', 'type': 'list', 'children': ['97', '98'], 'value': '[left, right]'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '102', 'type': 'not_operator', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '104', 'type': 'if_statement', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'one_based'}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '110', 'type': 'list_comprehension', 'children': ['111', '114']}; {'id': '111', 'type': 'binary_operator', 'children': ['112', '113'], 'value': '+'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '113', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '114', 'type': 'for_in_clause', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124', '125']}; {'id': '123', 'type': 'string', 'children': [], 'value': '"{} sheets => page sequence {!r}"'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'n_sheets'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '126', 'type': 'return_statement', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'sequence'}
|
Generates the final page sequence from the starting number of sheets.
|
def close(self):
print("PGPooledTransaction - shutting down connection pool")
for name, conn in self.pool.iteritems():
conn.close()
print("PGPooledTransaction - connection %s closed" % name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '11']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"PGPooledTransaction - shutting down connection pool"'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '15', '22']}; {'id': '12', 'type': 'pattern_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'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': 'pool'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23', '29']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'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': '"PGPooledTransaction - connection %s closed"'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'name'}
|
close all pooled connections
|
def build_graph(self):
for child, parents in self.dependencies.items():
if child not in self.nodes:
raise NodeNotFoundError(
"App %s SQL item dependencies reference nonexistent child node %r" % (
child[0], child),
child
)
for parent in parents:
if parent not in self.nodes:
raise NodeNotFoundError(
"App %s SQL item dependencies reference nonexistent parent node %r" % (
child[0], parent),
parent
)
self.node_map[child].add_parent(self.node_map[parent])
self.node_map[parent].add_child(self.node_map[child])
for node in self.nodes:
self.ensure_not_cyclic(node,
lambda x: (parent.key for parent in self.node_map[x].parents))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_graph'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '90']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '17']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'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': 'dependencies'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '37']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '24']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'not in'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'NodeNotFoundError'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '36']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '%'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"App %s SQL item dependencies reference nonexistent child node %r"'}; {'id': '31', 'type': 'tuple', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '40', 'type': 'block', 'children': ['41', '60', '75']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '47']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'not in'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'raise_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'NodeNotFoundError'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '59']}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '%'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"App %s SQL item dependencies reference nonexistent parent node %r"'}; {'id': '54', 'type': 'tuple', 'children': ['55', '58']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '69']}; {'id': '62', 'type': 'attribute', 'children': ['63', '68']}; {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'node_map'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'add_parent'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'node_map'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '84']}; {'id': '77', 'type': 'attribute', 'children': ['78', '83']}; {'id': '78', 'type': 'subscript', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'node_map'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'add_child'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'subscript', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'node_map'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '90', 'type': 'for_statement', 'children': ['91', '92', '95']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ensure_not_cyclic'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '103', 'type': 'lambda', 'children': ['104', '106']}; {'id': '104', 'type': 'lambda_parameters', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '106', 'type': 'generator_expression', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '110', 'type': 'for_in_clause', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '112', 'type': 'attribute', 'children': ['113', '118']}; {'id': '113', 'type': 'subscript', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'node_map'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'parents'}
|
Read lazy dependency list and build graph.
|
def recompile_all(path):
import os
if os.path.isdir(path):
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith('.py'):
filename = os.path.abspath(os.path.join(root, name))
print >> sys.stderr, filename
recompile(filename)
else:
filename = os.path.abspath(path)
recompile(filename)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recompile_all'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6', '9']}; {'id': '6', 'type': 'import_statement', 'children': ['7']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '9', 'type': 'if_statement', 'children': ['10', '18', '73']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'for_statement', 'children': ['20', '24', '30']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '42']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'.py'"}; {'id': '42', 'type': 'block', 'children': ['43', '62', '68']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'os'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '52', 'type': 'argument_list', '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': 'os'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '62', 'type': 'print_statement', 'children': ['63', '67']}; {'id': '63', 'type': 'chevron', 'children': ['64']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'recompile'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '73', 'type': 'else_clause', 'children': ['74']}; {'id': '74', 'type': 'block', 'children': ['75', '86']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '78', 'type': 'call', 'children': ['79', '84']}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'recompile'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'filename'}
|
recursively recompile all .py files in the directory
|
def summary(app):
r = requests.get('https://{}.herokuapp.com/summary'.format(app))
summary = r.json()['summary']
click.echo("\nstatus \t| count")
click.echo("----------------")
for s in summary:
click.echo("{}\t| {}".format(s[0], s[1]))
num_101s = sum([s[1] for s in summary if s[0] == 101])
num_10xs = sum([s[1] for s in summary if s[0] >= 100])
if num_10xs > 0:
click.echo("\nYield: {:.2%}".format(1.0 * num_101s / num_10xs))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'summary'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '30', '37', '44', '65', '84', '103']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'https://{}.herokuapp.com/summary'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '23', 'type': 'subscript', 'children': ['24', '29']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'string', 'children': [], 'value': "'summary'"}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"\\nstatus \\t| count"'}; {'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': 'click'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"----------------"'}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'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': 'click'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': '"{}\\t| {}"'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '62']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'num_101s'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'list_comprehension', 'children': ['72', '75', '78']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '75', 'type': 'for_in_clause', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '78', 'type': 'if_clause', 'children': ['79']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '83'], 'value': '=='}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '101'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'num_10xs'}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'list_comprehension', 'children': ['91', '94', '97']}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '94', 'type': 'for_in_clause', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '97', 'type': 'if_clause', 'children': ['98']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '102'], 'value': '>='}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '103', 'type': 'if_statement', 'children': ['104', '107']}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '106'], 'value': '>'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'num_10xs'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'click'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'string', 'children': [], 'value': '"\\nYield: {:.2%}"'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '123'], 'value': '/'}; {'id': '120', 'type': 'binary_operator', 'children': ['121', '122'], 'value': '*'}; {'id': '121', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'num_101s'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'num_10xs'}
|
Print a summary of a deployed app's status.
|
def command_line_runner():
parser = get_parser()
args = vars(parser.parse_args())
if args['version']:
print(__version__)
return
if args['clear_cache']:
utils.clear_cache()
print('Cleared {0}.'.format(utils.CACHE_DIR))
return
if not args['query']:
parser.print_help()
return
if not os.getenv('SCRAPE_DISABLE_CACHE'):
utils.enable_cache()
if os.getenv('SCRAPE_DISABLE_IMGS'):
args['no_images'] = True
prompt_filetype(args)
prompt_save_images(args)
scrape(args)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'command_line_runner'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '22', '33', '57', '70', '85', '99', '104', '109']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'get_parser'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'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': 'parser'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'parse_args'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'version'"}; {'id': '26', 'type': 'block', 'children': ['27', '32']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '__version__'}; {'id': '32', 'type': 'return_statement', 'children': []}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'clear_cache'"}; {'id': '37', 'type': 'block', 'children': ['38', '44', '56']}; {'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': 'utils'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'clear_cache'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'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': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'Cleared {0}.'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'CACHE_DIR'}; {'id': '56', 'type': 'return_statement', 'children': []}; {'id': '57', 'type': 'if_statement', 'children': ['58', '62']}; {'id': '58', 'type': 'not_operator', 'children': ['59']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'query'"}; {'id': '62', 'type': 'block', 'children': ['63', '69']}; {'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': 'parser'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'print_help'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'return_statement', 'children': []}; {'id': '70', 'type': 'if_statement', 'children': ['71', '78']}; {'id': '71', 'type': 'not_operator', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'getenv'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'SCRAPE_DISABLE_CACHE'"}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'enable_cache'}; {'id': '84', 'type': 'argument_list', 'children': []}; {'id': '85', 'type': 'if_statement', 'children': ['86', '92']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'getenv'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'SCRAPE_DISABLE_IMGS'"}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '98']}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '97', 'type': 'string', 'children': [], 'value': "'no_images'"}; {'id': '98', 'type': 'True', 'children': []}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'prompt_filetype'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'prompt_save_images'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'scrape'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'args'}
|
Handle command-line interaction.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.