code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def mode(self):
if self._resources is None:
self.__init()
if "mode" in self._resources:
url = self._url + "/mode"
return _mode.Mode(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_resources'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'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': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__init'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '25', '61']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'in'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"mode"'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_resources'}; {'id': '25', 'type': 'block', 'children': ['26', '34']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '33'], 'value': '+'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"/mode"'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_mode'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Mode'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43', '48', '53', '58']}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'initialize'}; {'id': '60', 'type': 'True', 'children': []}; {'id': '61', 'type': 'else_clause', 'children': ['62']}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'None', 'children': []}
|
returns an object to work with the site mode
|
def convert_out(self, obj):
newobj = super(ProcessedImageProduct, self).convert_out(obj)
if newobj:
hdulist = newobj.open()
hdr = hdulist[0].header
if 'EMIRUUID' not in hdr:
hdr['EMIRUUID'] = str(uuid.uuid1())
return newobj
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_out'}; {'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', '20', '57']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'newobj'}; {'id': '10', 'type': 'call', 'children': ['11', '18']}; {'id': '11', 'type': 'attribute', 'children': ['12', '17']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ProcessedImageProduct'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'convert_out'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'newobj'}; {'id': '22', 'type': 'block', 'children': ['23', '31', '39']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hdulist'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'newobj'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'hdulist'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '39', 'type': 'if_statement', 'children': ['40', '43']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'not in'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'EMIRUUID'"}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'EMIRUUID'"}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'uuid1'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'newobj'}
|
Write EMIRUUID header on reduction
|
def directories(self):
directories_description = [
self.project_name,
self.project_name + '/conf',
self.project_name + '/static',
]
return directories_description
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'directories'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'directories_description'}; {'id': '9', 'type': 'list', 'children': ['10', '13', '18'], 'value': "[\n self.project_name,\n self.project_name + '/conf',\n self.project_name + '/static',\n ]"}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'project_name'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '17'], 'value': '+'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'project_name'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'/conf'"}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '+'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'project_name'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'/static'"}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'directories_description'}
|
Return the names of directories to be created.
|
def filter_extant_exports(client, bucket, prefix, days, start, end=None):
end = end or datetime.now()
try:
tag_set = client.get_object_tagging(Bucket=bucket, Key=prefix).get('TagSet', [])
except ClientError as e:
if e.response['Error']['Code'] != 'NoSuchKey':
raise
tag_set = []
tags = {t['Key']: t['Value'] for t in tag_set}
if 'LastExport' not in tags:
return sorted(days)
last_export = parse(tags['LastExport'])
if last_export.tzinfo is None:
last_export = last_export.replace(tzinfo=tzutc())
return [d for d in sorted(days) if d > last_export]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_extant_exports'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '23', '67', '81', '91', '100', '120']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '18'], 'value': 'or'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'try_statement', 'children': ['24', '45']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tag_set'}; {'id': '28', 'type': 'call', 'children': ['29', '42']}; {'id': '29', 'type': 'attribute', 'children': ['30', '41']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get_object_tagging'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '38']}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Bucket'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Key'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'TagSet'"}; {'id': '44', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '45', 'type': 'except_clause', 'children': ['46', '50']}; {'id': '46', 'type': 'as_pattern', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ClientError'}; {'id': '48', 'type': 'as_pattern_target', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '50', 'type': 'block', 'children': ['51', '63']}; {'id': '51', 'type': 'if_statement', 'children': ['52', '61']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '60'], 'value': '!='}; {'id': '53', 'type': 'subscript', 'children': ['54', '59']}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'Error'"}; {'id': '59', 'type': 'string', 'children': [], 'value': "'Code'"}; {'id': '60', 'type': 'string', 'children': [], 'value': "'NoSuchKey'"}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'raise_statement', 'children': []}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'tag_set'}; {'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': 'tags'}; {'id': '70', 'type': 'dictionary_comprehension', 'children': ['71', '78']}; {'id': '71', 'type': 'pair', 'children': ['72', '75']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'Key'"}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'Value'"}; {'id': '78', 'type': 'for_in_clause', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'tag_set'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '85']}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '84'], 'value': 'not in'}; {'id': '83', 'type': 'string', 'children': [], 'value': "'LastExport'"}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'last_export'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'subscript', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '99', 'type': 'string', 'children': [], 'value': "'LastExport'"}; {'id': '100', 'type': 'if_statement', 'children': ['101', '106']}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '105'], 'value': 'is'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'last_export'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'tzinfo'}; {'id': '105', 'type': 'None', 'children': []}; {'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': 'last_export'}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'last_export'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'keyword_argument', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'tzinfo'}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'tzutc'}; {'id': '119', 'type': 'argument_list', 'children': []}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'list_comprehension', 'children': ['122', '123', '129']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '123', 'type': 'for_in_clause', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '129', 'type': 'if_clause', 'children': ['130']}; {'id': '130', 'type': 'comparison_operator', 'children': ['131', '132'], 'value': '>'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'last_export'}
|
Filter days where the bucket already has extant export keys.
|
def find_netmiko_dir():
try:
netmiko_base_dir = os.environ["NETMIKO_DIR"]
except KeyError:
netmiko_base_dir = NETMIKO_BASE_DIR
netmiko_base_dir = os.path.expanduser(netmiko_base_dir)
if netmiko_base_dir == "/":
raise ValueError("/ cannot be netmiko_base_dir")
netmiko_full_dir = "{}/tmp".format(netmiko_base_dir)
return (netmiko_base_dir, netmiko_full_dir)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_netmiko_dir'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '22', '33', '43', '52']}; {'id': '5', 'type': 'try_statement', 'children': ['6', '15']}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'netmiko_base_dir'}; {'id': '10', 'type': 'subscript', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"NETMIKO_DIR"'}; {'id': '15', 'type': 'except_clause', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'netmiko_base_dir'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'NETMIKO_BASE_DIR'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'netmiko_base_dir'}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'netmiko_base_dir'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': '=='}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'netmiko_base_dir'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'raise_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"/ cannot be netmiko_base_dir"'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'netmiko_full_dir'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"{}/tmp"'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'netmiko_base_dir'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'tuple', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'netmiko_base_dir'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'netmiko_full_dir'}
|
Check environment first, then default dir
|
def parse_trailer(header):
pos = 0
names = []
while pos < len(header):
name, pos = expect_re(re_token, header, pos)
if name:
names.append(name)
_, pos = accept_ws(header, pos)
_, pos = expect_lit(',', header, pos)
_, pos = accept_ws(header, pos)
return names
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_trailer'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '74']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '13', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '14', 'type': 'while_statement', 'children': ['15', '21']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '<'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '21', 'type': 'block', 'children': ['22', '33', '43', '53', '64']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'pattern_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'expect_re'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 're_token'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'pattern_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'accept_ws'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '58']}; {'id': '55', 'type': 'pattern_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'expect_lit'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'string', 'children': [], 'value': "','"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '69']}; {'id': '66', 'type': 'pattern_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'accept_ws'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'names'}
|
Parse the "Trailer" header.
|
def on_error(self, status_code):
logger.error('Twitter returned error code %s', status_code)
self.error = status_code
return False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_error'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '21']}; {'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': 'logger'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'Twitter returned error code %s'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'False', 'children': []}
|
Called when a non-200 status code is returned
|
def FUNCTIONNOPROTO(self, _cursor_type):
returns = _cursor_type.get_result()
returns = self.parse_cursor_type(returns)
attributes = []
obj = typedesc.FunctionType(returns, attributes)
self.set_location(obj, None)
return obj
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'FUNCTIONNOPROTO'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': '_cursor_type'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '24', '28', '38', '46']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_cursor_type'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_result'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'parse_cursor_type'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '27', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'typedesc'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'FunctionType'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'returns'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'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': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'set_location'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'obj'}
|
Handles function with no prototype.
|
def draw_segments(image, segments, color=(255, 0, 0), line_width=1):
for segment in segments:
x, y, w, h = segment
cv2.rectangle(image, (x, y), (x + w, y + h), color, line_width)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'draw_segments'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'segments'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '8', 'type': 'tuple', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'integer', 'children': [], 'value': '255'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'line_width'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'segment'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'segments'}; {'id': '19', 'type': 'block', 'children': ['20', '28']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '27']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24', '25', '26']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'segment'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'cv2'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'rectangle'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35', '38', '45', '46']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '35', 'type': 'tuple', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '38', 'type': 'tuple', 'children': ['39', '42']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '+'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '+'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'line_width'}
|
draws segments on image
|
def delete(cls, id):
client = cls._new_api_client()
return client.make_request(cls, 'delete', url_params={'id': id})
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'block', 'children': ['7', '15']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_new_api_client'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'make_request'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'delete'"}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'url_params'}; {'id': '25', 'type': 'dictionary', 'children': ['26']}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'id'}
|
Destroy a Union object
|
def add(image_path, file_name=None):
if file_name is not None:
dst_path = os.path.join(IMG_DIR, str(Path(file_name).stem + Path(image_path).suffix))
else:
dst_path = IMG_DIR
if os.path.isfile(image_path):
shutil.copy2(image_path, dst_path)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'image_path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '47']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13', '41']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is not'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '12', 'type': 'None', 'children': []}; {'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': 'dst_path'}; {'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': 'join'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'IMG_DIR'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '35'], 'value': '+'}; {'id': '29', 'type': 'attribute', 'children': ['30', '34']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'stem'}; {'id': '35', 'type': 'attribute', 'children': ['36', '40']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'image_path'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dst_path'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'IMG_DIR'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '56']}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'image_path'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'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': 'shutil'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'copy2'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'image_path'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'dst_path'}
|
Add an image to the GUI img library.
|
def stage_http_response2(self, payload):
if not self._http_response_version and not payload:
return
if self.enabled and self.http_detail_level is not None and \
self.httplogger.isEnabledFor(logging.DEBUG):
if self._http_response_headers:
header_str = \
' '.join('{0}:{1!r}'.format(k, v)
for k, v in self._http_response_headers.items())
else:
header_str = ''
if self.http_detail_level == 'summary':
upayload = ""
elif self.http_maxlen and (len(payload) > self.http_maxlen):
upayload = (_ensure_unicode(payload[:self.http_maxlen]) +
'...')
else:
upayload = _ensure_unicode(payload)
self.httplogger.debug('Response:%s %s:%s %s %s\n %s',
self._http_response_conn_id,
self._http_response_status,
self._http_response_reason,
self._http_response_version,
header_str, upayload)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stage_http_response2'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '13'], 'value': 'and'}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_http_response_version'}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': []}; {'id': '17', 'type': 'if_statement', 'children': ['18', '39']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '28', '29'], 'value': 'and'}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '23'], 'value': 'and'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'enabled'}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': 'is not'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'http_detail_level'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'httplogger'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'isEnabledFor'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'DEBUG'}; {'id': '39', 'type': 'block', 'children': ['40', '77', '128']}; {'id': '40', 'type': 'if_statement', 'children': ['41', '44', '71']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_http_response_headers'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'header_str'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '52', 'type': 'generator_expression', 'children': ['53', '60']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'{0}:{1!r}'"}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '60', 'type': 'for_in_clause', 'children': ['61', '64']}; {'id': '61', 'type': 'pattern_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'v'}; {'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': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_http_response_headers'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '70', 'type': 'argument_list', 'children': []}; {'id': '71', 'type': 'else_clause', 'children': ['72']}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'header_str'}; {'id': '76', 'type': 'string', 'children': [], 'value': "''"}; {'id': '77', 'type': 'if_statement', 'children': ['78', '83', '88', '119']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '82'], 'value': '=='}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'http_detail_level'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'summary'"}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'upayload'}; {'id': '87', 'type': 'string', 'children': [], 'value': '""'}; {'id': '88', 'type': 'elif_clause', 'children': ['89', '102']}; {'id': '89', 'type': 'boolean_operator', 'children': ['90', '93'], 'value': 'and'}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'http_maxlen'}; {'id': '93', 'type': '()', 'children': ['94']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '99'], 'value': '>'}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'http_maxlen'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'upayload'}; {'id': '106', 'type': '()', 'children': ['107']}; {'id': '107', 'type': 'binary_operator', 'children': ['108', '118'], 'value': '+'}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '_ensure_unicode'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'subscript', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '113', 'type': 'slice', 'children': ['114', '115']}; {'id': '114', 'type': 'colon', 'children': []}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'http_maxlen'}; {'id': '118', 'type': 'string', 'children': [], 'value': "'...'"}; {'id': '119', 'type': 'else_clause', 'children': ['120']}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'upayload'}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': '_ensure_unicode'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '135']}; {'id': '130', 'type': 'attribute', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'httplogger'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '135', 'type': 'argument_list', 'children': ['136', '137', '140', '143', '146', '149', '150']}; {'id': '136', 'type': 'string', 'children': [], 'value': "'Response:%s %s:%s %s %s\\n %s'"}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': '_http_response_conn_id'}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': '_http_response_status'}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': '_http_response_reason'}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': '_http_response_version'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'header_str'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'upayload'}
|
Log complete http response, including response1 and payload
|
def _maximize(self):
if not self.space.is_observations_valid():
return None
y_max = self.space.y.max()
self.utility_function.gaussian_process.fit(self.space.x, self.space.y)
return self.utility_function.max_compute(y_max=y_max,
bounds=self.space.bounds,
n_warmup=self.n_warmup,
n_iter=self.n_iter)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_maximize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '30', '50']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'not_operator', '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': 'space'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'is_observations_valid'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'y_max'}; {'id': '21', 'type': 'call', 'children': ['22', '29']}; {'id': '22', 'type': 'attribute', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'space'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '39']}; {'id': '32', 'type': 'attribute', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'utility_function'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'gaussian_process'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fit'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'space'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'space'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '50', 'type': 'return_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': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'utility_function'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'max_compute'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '61', '68', '73']}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'y_max'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'y_max'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'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': 'space'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'n_warmup'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'n_warmup'}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'n_iter'}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'n_iter'}
|
Find argmax of the acquisition function.
|
def _do_help(self, cmd, args):
print(self.doc_string())
print()
data_unsorted = []
cls = self.__class__
for name in dir(cls):
obj = getattr(cls, name)
if iscommand(obj):
cmds = []
for cmd in getcommands(obj):
cmds.append(cmd)
cmd_str = ','.join(sorted(cmds))
doc_str = textwrap.dedent(obj.__doc__).strip() if obj.__doc__ else \
'(no doc string available)'
data_unsorted.append([cmd_str, doc_str])
data_sorted = sorted(data_unsorted, key = lambda x: x[0])
data = [['COMMANDS', 'DOC STRING']] + data_sorted
table_banner = 'List of Available Commands'
table = terminaltables.SingleTable(data, table_banner)
table.inner_row_border = True
table.inner_heading_row_border = True
print(table.table)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_do_help'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '21', '25', '31', '111', '126', '135', '139', '149', '155', '161']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'doc_string'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data_unsorted'}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '37']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'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': 'obj'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '51']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'iscommand'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '51', 'type': 'block', 'children': ['52', '56', '70', '82', '102']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cmds'}; {'id': '55', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '56', 'type': 'for_statement', 'children': ['57', '58', '62']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'getcommands'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'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': 'cmds'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'cmd_str'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': "','"}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'cmds'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'doc_str'}; {'id': '85', 'type': 'conditional_expression', 'children': ['86', '98', '101'], 'value': 'if'}; {'id': '86', 'type': 'call', 'children': ['87', '97']}; {'id': '87', 'type': 'attribute', 'children': ['88', '96']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'textwrap'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'dedent'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '97', 'type': 'argument_list', 'children': []}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'(no doc string available)'"}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'data_unsorted'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'list', 'children': ['109', '110'], 'value': '[cmd_str, doc_str]'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'cmd_str'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'doc_str'}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'data_sorted'}; {'id': '114', 'type': 'call', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'data_unsorted'}; {'id': '118', 'type': 'keyword_argument', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '120', 'type': 'lambda', 'children': ['121', '123']}; {'id': '121', 'type': 'lambda_parameters', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '123', 'type': 'subscript', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '125', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '129', 'type': 'binary_operator', 'children': ['130', '134'], 'value': '+'}; {'id': '130', 'type': 'list', 'children': ['131'], 'value': "[['COMMANDS', 'DOC STRING']]"}; {'id': '131', 'type': 'list', 'children': ['132', '133'], 'value': "['COMMANDS', 'DOC STRING']"}; {'id': '132', 'type': 'string', 'children': [], 'value': "'COMMANDS'"}; {'id': '133', 'type': 'string', 'children': [], 'value': "'DOC STRING'"}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'data_sorted'}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'table_banner'}; {'id': '138', 'type': 'string', 'children': [], 'value': "'List of Available Commands'"}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'terminaltables'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'SingleTable'}; {'id': '146', 'type': 'argument_list', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'table_banner'}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'inner_row_border'}; {'id': '154', 'type': 'True', 'children': []}; {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'assignment', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'inner_heading_row_border'}; {'id': '160', 'type': 'True', 'children': []}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'table'}
|
Display doc strings of the shell and its commands.
|
def add_subcommands(parser, commands):
"Add commands to a parser"
subps = parser.add_subparsers()
for cmd, cls in commands:
subp = subps.add_parser(cmd, help=cls.__doc__)
add_args = getattr(cls, 'add_arguments', None)
if add_args:
add_args(subp)
handler = getattr(cls, 'handle', None)
if handler:
subp.set_defaults(handler=handler)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_subcommands'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Add commands to a parser"'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'subps'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'add_subparsers'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'for_statement', 'children': ['18', '21', '22']}; {'id': '18', 'type': 'pattern_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '22', 'type': 'block', 'children': ['23', '37', '46', '54', '63']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'subp'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'subps'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'add_parser'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'add_args'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'add_arguments'"}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'if_statement', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'add_args'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'add_args'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'subp'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'handle'"}; {'id': '62', 'type': 'None', 'children': []}; {'id': '63', 'type': 'if_statement', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'subp'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'set_defaults'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'handler'}
|
Add commands to a parser
|
def _replace_token_range(tokens, start, end, replacement):
tokens = tokens[:start] + replacement + tokens[end:]
return tokens
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_replace_token_range'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'replacement'}; {'id': '8', 'type': 'block', 'children': ['9', '25']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '20'], 'value': '+'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '19'], 'value': '+'}; {'id': '14', 'type': 'subscript', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '16', 'type': 'slice', 'children': ['17', '18']}; {'id': '17', 'type': 'colon', 'children': []}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'replacement'}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '22', 'type': 'slice', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '24', 'type': 'colon', 'children': []}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'tokens'}
|
For a range indicated from start to end, replace with replacement.
|
def merge_from(self, other):
if other.national_number_pattern is not None:
self.national_number_pattern = other.national_number_pattern
if other.example_number is not None:
self.example_number = other.example_number
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_from'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '6', 'type': 'block', 'children': ['7', '22']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is not'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'national_number_pattern'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'national_number_pattern'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'national_number_pattern'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '28']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': 'is not'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'example_number'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'example_number'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'example_number'}
|
Merge information from another PhoneNumberDesc object into this one.
|
def _count_pixels_on_line(self, y, p):
h = line(y, self._effective_thickness(p), 0.0)
return h.sum()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_count_pixels_on_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '7', 'type': 'block', 'children': ['8', '22']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '21']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'y'}; {'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': '_effective_thickness'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '21', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '27', 'type': 'argument_list', 'children': []}
|
Count the number of pixels rendered on this line.
|
def _compare_match(dict1, dict2):
for karg, warg in six.iteritems(dict1):
if karg in dict2 and dict2[karg] != warg:
return False
return True
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_compare_match'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dict1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dict2'}; {'id': '6', 'type': 'block', 'children': ['7', '31']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '11', '17']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'karg'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'warg'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dict1'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '28']}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '23'], 'value': 'and'}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'in'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'karg'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dict2'}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': '!='}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dict2'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'karg'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'warg'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'False', 'children': []}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'True', 'children': []}
|
Compare two dictionaries and return a boolean value if their values match.
|
def map_overview_header_element(feature, parent):
_ = feature, parent
header = map_overview_header['string_format']
return header.capitalize()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_overview_header_element'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '10', 'type': 'expression_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'map_overview_header'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'string_format'"}; {'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': 'header'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'capitalize'}; {'id': '24', 'type': 'argument_list', 'children': []}
|
Retrieve map overview header string from definitions.
|
async def observer_evaluate(self, message):
observer_id = message['observer']
throttle_rate = get_queryobserver_settings()['throttle_rate']
if throttle_rate <= 0:
await self._evaluate(observer_id)
return
cache_key = throttle_cache_key(observer_id)
try:
count = cache.incr(cache_key)
if count == 2:
await self.channel_layer.send(
CHANNEL_MAIN,
{
'type': TYPE_POLL,
'observer': observer_id,
'interval': throttle_rate,
},
)
except ValueError:
count = cache.get_or_set(cache_key, default=1, timeout=throttle_rate)
if count == 1:
await self._evaluate(observer_id)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'observer_evaluate'}; {'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', '13', '21', '35', '42']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'observer_id'}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'observer'"}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'throttle_rate'}; {'id': '16', 'type': 'subscript', 'children': ['17', '20']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_queryobserver_settings'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'string', 'children': [], 'value': "'throttle_rate'"}; {'id': '21', 'type': 'if_statement', 'children': ['22', '25']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': '<='}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'throttle_rate'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '25', 'type': 'block', 'children': ['26', '34']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'await', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_evaluate'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'observer_id'}; {'id': '34', 'type': 'return_statement', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cache_key'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'throttle_cache_key'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'observer_id'}; {'id': '42', 'type': 'try_statement', 'children': ['43', '78']}; {'id': '43', 'type': 'block', 'children': ['44', '53']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'incr'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'cache_key'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '57']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': '=='}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'await', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'channel_layer'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'CHANNEL_MAIN'}; {'id': '68', 'type': 'dictionary', 'children': ['69', '72', '75']}; {'id': '69', 'type': 'pair', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'TYPE_POLL'}; {'id': '72', 'type': 'pair', 'children': ['73', '74']}; {'id': '73', 'type': 'string', 'children': [], 'value': "'observer'"}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'observer_id'}; {'id': '75', 'type': 'pair', 'children': ['76', '77']}; {'id': '76', 'type': 'string', 'children': [], 'value': "'interval'"}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'throttle_rate'}; {'id': '78', 'type': 'except_clause', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '80', 'type': 'block', 'children': ['81', '96']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'get_or_set'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90', '93']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'cache_key'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'throttle_rate'}; {'id': '96', 'type': 'if_statement', 'children': ['97', '100']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': '=='}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '99', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'await', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': '_evaluate'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'observer_id'}
|
Execute observer evaluation on the worker or throttle.
|
def visit_list(self, node, parent):
context = self._get_context(node)
newnode = nodes.List(
ctx=context, lineno=node.lineno, col_offset=node.col_offset, parent=parent
)
newnode.postinit([self.visit(child, newnode) for child in node.elts])
return newnode
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_list'}; {'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': 'parent'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '41', '60']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_get_context'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '28', '33', '38']}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'col_offset'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'col_offset'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'postinit'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'list_comprehension', 'children': ['48', '55']}; {'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': 'visit'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'newnode'}; {'id': '55', 'type': 'for_in_clause', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'elts'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'newnode'}
|
visit a List node by returning a fresh instance of it
|
def atom_by_serialnumber(self):
atm_by_snum = {}
for atom in self.model.atoms:
atm_by_snum[atom.serialNumber] = atom
return atm_by_snum
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'atom_by_serialnumber'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'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': 'atm_by_snum'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '17']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'atom'}; {'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': 'model'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'atoms'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '25']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'atm_by_snum'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'atom'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'serialNumber'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'atom'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'atm_by_snum'}
|
Provides a dictionary mapping serial numbers to their atom objects.
|
def server_list(endpoint_id):
endpoint, server_list = get_endpoint_w_server_list(endpoint_id)
if server_list == "S3":
server_list = {"s3_url": endpoint["s3_url"]}
fields = [("S3 URL", "s3_url")]
text_format = FORMAT_TEXT_RECORD
else:
fields = (
("ID", "id"),
("URI", lambda s: (s["uri"] or "none (Globus Connect Personal)")),
)
text_format = FORMAT_TEXT_TABLE
formatted_print(server_list, text_format=text_format, fields=fields)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'server_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'endpoint_id'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '64']}; {'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': 'endpoint'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'server_list'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_endpoint_w_server_list'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'endpoint_id'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19', '40']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '=='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'server_list'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"S3"'}; {'id': '19', 'type': 'block', 'children': ['20', '29', '36']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'server_list'}; {'id': '23', 'type': 'dictionary', 'children': ['24']}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"s3_url"'}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"s3_url"'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '32', 'type': 'list', 'children': ['33'], 'value': '[("S3 URL", "s3_url")]'}; {'id': '33', 'type': 'tuple', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"S3 URL"'}; {'id': '35', 'type': 'string', 'children': [], 'value': '"s3_url"'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'text_format'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'FORMAT_TEXT_RECORD'}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42', '60']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '45', 'type': 'tuple', 'children': ['46', '49']}; {'id': '46', 'type': 'tuple', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"ID"'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '49', 'type': 'tuple', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': '"URI"'}; {'id': '51', 'type': 'lambda', 'children': ['52', '54']}; {'id': '52', 'type': 'lambda_parameters', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '54', 'type': '()', 'children': ['55']}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '59'], 'value': 'or'}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"uri"'}; {'id': '59', 'type': 'string', 'children': [], 'value': '"none (Globus Connect Personal)"'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'text_format'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'FORMAT_TEXT_TABLE'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'formatted_print'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '72']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'server_list'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'text_format'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'text_format'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'fields'}
|
Executor for `globus endpoint server list`
|
def Get(self, attribute, default=None):
if attribute is None:
return default
elif isinstance(attribute, str):
attribute = Attribute.GetAttributeByName(attribute)
if "r" not in self.mode and (attribute not in self.new_attributes and
attribute not in self.synced_attributes):
raise IOError("Fetching %s from object not opened for reading." %
attribute)
for result in self.GetValuesForAttribute(attribute, only_one=True):
try:
result.attribute_instance = attribute
except AttributeError:
pass
return result
return attribute.GetDefault(self, default)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'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', '33', '60', '86']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14', '17']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '17', 'type': 'elif_clause', 'children': ['18', '23']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Attribute'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'GetAttributeByName'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '52']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '40'], 'value': 'and'}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'not in'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"r"'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'boolean_operator', 'children': ['42', '47'], 'value': 'and'}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'not in'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'new_attributes'}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'not in'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'synced_attributes'}; {'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': 'IOError'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '%'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"Fetching %s from object not opened for reading."'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '60', 'type': 'for_statement', 'children': ['61', '62', '71']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'GetValuesForAttribute'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'only_one'}; {'id': '70', 'type': 'True', 'children': []}; {'id': '71', 'type': 'block', 'children': ['72', '84']}; {'id': '72', 'type': 'try_statement', 'children': ['73', '80']}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'attribute_instance'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '80', 'type': 'except_clause', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'pass_statement', 'children': []}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'GetDefault'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'default'}
|
Gets the attribute from this object.
|
def sample_frame_single_env(self, batch_size, forward_steps=1):
if self.current_size < self.buffer_capacity:
return np.random.choice(self.current_size - forward_steps, batch_size, replace=False)
else:
candidate = np.random.choice(self.buffer_capacity, batch_size, replace=False)
forbidden_ones = (
np.arange(self.current_idx - forward_steps + 1, self.current_idx + self.frame_history)
% self.buffer_capacity
)
while any(x in candidate for x in forbidden_ones):
candidate = np.random.choice(self.buffer_capacity, batch_size, replace=False)
return candidate
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sample_frame_single_env'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'forward_steps'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '18', '36']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '15'], 'value': '<'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'current_size'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'buffer_capacity'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_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': 'np'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'choice'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '32', '33']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '31'], 'value': '-'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'current_size'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'forward_steps'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '35', 'type': 'False', 'children': []}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38', '55', '82', '110']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'candidate'}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'choice'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '51', '52']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'buffer_capacity'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '54', 'type': 'False', 'children': []}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'forbidden_ones'}; {'id': '58', 'type': '()', 'children': ['59']}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '79'], 'value': '%'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'arange'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '72']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '71'], 'value': '+'}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '70'], 'value': '-'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'current_idx'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'forward_steps'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '76'], 'value': '+'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'current_idx'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'frame_history'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'buffer_capacity'}; {'id': '82', 'type': 'while_statement', 'children': ['83', '92']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '85', 'type': 'generator_expression', 'children': ['86', '89']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '88'], 'value': 'in'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'candidate'}; {'id': '89', 'type': 'for_in_clause', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'forbidden_ones'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'candidate'}; {'id': '96', 'type': 'call', 'children': ['97', '102']}; {'id': '97', 'type': 'attribute', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'choice'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '106', '107']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'buffer_capacity'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '107', 'type': 'keyword_argument', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '109', 'type': 'False', 'children': []}; {'id': '110', 'type': 'return_statement', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'candidate'}
|
Return an in index of a random set of frames from a buffer, that have enough history and future
|
def DosDateTimeToTimeTuple(dosDateTime):
dos_date = dosDateTime >> 16
dos_time = dosDateTime & 0xffff
day = dos_date & 0x1f
month = (dos_date >> 5) & 0xf
year = 1980 + (dos_date >> 9)
second = 2 * (dos_time & 0x1f)
minute = (dos_time >> 5) & 0x3f
hour = dos_time >> 11
return time.localtime(
time.mktime((year, month, day, hour, minute, second, 0, 1, -1)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DosDateTimeToTimeTuple'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dosDateTime'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '24', '33', '42', '51', '60', '66']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'dos_date'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '11'], 'value': '>>'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dosDateTime'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dos_time'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '&'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dosDateTime'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0xffff'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '&'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dos_date'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0x1f'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '32'], 'value': '&'}; {'id': '28', 'type': '()', 'children': ['29']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '>>'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'dos_date'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0xf'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '+'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1980'}; {'id': '38', 'type': '()', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '>>'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'dos_date'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'second'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '*'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '47', 'type': '()', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '&'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'dos_time'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0x1f'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'minute'}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '59'], 'value': '&'}; {'id': '55', 'type': '()', 'children': ['56']}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '>>'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'dos_time'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0x3f'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'hour'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '>>'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'dos_time'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'localtime'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'mktime'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'tuple', 'children': ['78', '79', '80', '81', '82', '83', '84', '85', '86']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'hour'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'minute'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'second'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '86', 'type': 'unary_operator', 'children': ['87'], 'value': '-'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}
|
Convert an MS-DOS format date time to a Python time tuple.
|
def batch_contains_deleted(self):
"Check if current batch contains already deleted images."
if not self._duplicates: return False
imgs = [self._all_images[:self._batch_size][0][1], self._all_images[:self._batch_size][1][1]]
return any(img in self._deleted_fns for img in imgs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'batch_contains_deleted'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '16', '46']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Check if current batch contains already deleted images."'}; {'id': '8', 'type': 'if_statement', 'children': ['9', '13']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_duplicates'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'False', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'imgs'}; {'id': '19', 'type': 'list', 'children': ['20', '33'], 'value': '[self._all_images[:self._batch_size][0][1], self._all_images[:self._batch_size][1][1]]'}; {'id': '20', 'type': 'subscript', 'children': ['21', '32']}; {'id': '21', 'type': 'subscript', 'children': ['22', '31']}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_all_images'}; {'id': '26', 'type': 'slice', 'children': ['27', '28']}; {'id': '27', 'type': 'colon', 'children': []}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_batch_size'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '33', 'type': 'subscript', 'children': ['34', '45']}; {'id': '34', 'type': 'subscript', 'children': ['35', '44']}; {'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': '_all_images'}; {'id': '39', 'type': 'slice', 'children': ['40', '41']}; {'id': '40', 'type': 'colon', 'children': []}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_batch_size'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '49', 'type': 'generator_expression', 'children': ['50', '55']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': 'in'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_deleted_fns'}; {'id': '55', 'type': 'for_in_clause', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'imgs'}
|
Check if current batch contains already deleted images.
|
def _parent_foreign_key_mappings(cls):
parent_rel = cls.__mapper__.relationships.get(cls.export_parent)
if parent_rel:
return {l.name: r.name for (l, r) in parent_rel.local_remote_pairs}
return {}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parent_foreign_key_mappings'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '21', '40']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parent_rel'}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '__mapper__'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'relationships'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'export_parent'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'parent_rel'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'dictionary_comprehension', 'children': ['26', '33']}; {'id': '26', 'type': 'pair', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'for_in_clause', 'children': ['34', '37']}; {'id': '34', 'type': 'tuple_pattern', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'parent_rel'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'local_remote_pairs'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'dictionary', 'children': []}
|
Get a mapping of foreign name to the local name of foreign keys
|
def _cancel_orphan_orders(self, orderId):
orders = self.ibConn.orders
for order in orders:
order = orders[order]
if order['parentId'] != orderId:
self.ibConn.cancelOrder(order['id'])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cancel_orphan_orders'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'orderId'}; {'id': '6', 'type': 'block', 'children': ['7', '15']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'orders'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ibConn'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'orders'}; {'id': '15', 'type': 'for_statement', 'children': ['16', '17', '18']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'orders'}; {'id': '18', 'type': 'block', 'children': ['19', '25']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'orders'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '31']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '30'], 'value': '!='}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'parentId'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'orderId'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'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': 'ibConn'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cancelOrder'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'id'"}
|
cancel child orders when parent is gone
|
def authenticate(self, transport, account_name, password=None):
Authenticator.authenticate(self, transport, account_name, password)
if password == None:
return self.pre_auth(transport, account_name)
else:
return self.auth(transport, account_name, password)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authenticate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'account_name'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '21']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Authenticator'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'authenticate'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19', '20']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'account_name'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '25', '34']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': '=='}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_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': 'pre_auth'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'account_name'}; {'id': '34', 'type': 'else_clause', 'children': ['35']}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'account_name'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'password'}
|
Authenticates account using soap method.
|
def _get_products(self):
products_request = self.account_products()
if products_request['error']:
raise Exception(products_request['error'])
product_ids = []
for product in products_request["json"]["entries"]:
product_ids.append(product['productId'])
self.products = {}
for id in product_ids:
product_request = self.account_product(id)
if product_request['error']:
raise Exception(product_request['error'])
self.products[id] = product_request['json']
return self.products
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_products'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '26', '30', '47', '53', '88']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'products_request'}; {'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': 'account_products'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'products_request'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'error'"}; {'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': 'Exception'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'products_request'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'product_ids'}; {'id': '29', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '37']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'product'}; {'id': '32', 'type': 'subscript', 'children': ['33', '36']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'products_request'}; {'id': '35', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"entries"'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'product_ids'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'product'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'productId'"}; {'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': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'products'}; {'id': '52', 'type': 'dictionary', 'children': []}; {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'product_ids'}; {'id': '56', 'type': 'block', 'children': ['57', '66', '78']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'product_request'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'account_product'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '70']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'product_request'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'raise_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'product_request'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '85']}; {'id': '80', 'type': 'subscript', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'products'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'product_request'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'json'"}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'products'}
|
a method to retrieve account product details at initialization
|
def get(key, profile=None):
if not profile:
return False
redis_kwargs = profile.copy()
redis_kwargs.pop('driver')
redis_conn = redis.StrictRedis(**redis_kwargs)
return redis_conn.get(key)
|
{'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': 'key'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'profile'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '15', '23', '30', '40']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '12']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'profile'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'False', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'redis_kwargs'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'profile'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'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': 'redis_kwargs'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'driver'"}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'redis_conn'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'redis'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'StrictRedis'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'dictionary_splat', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'redis_kwargs'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'redis_conn'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'key'}
|
Get a value from the Redis SDB.
|
def _convert_key_to_str(key):
return salt.utils.data.encode(key) \
if six.PY2 and isinstance(key, unicode) \
else key
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_key_to_str'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'conditional_expression', 'children': ['8', '18', '19', '28', '29'], 'value': 'if'}; {'id': '8', 'type': 'call', 'children': ['9', '16']}; {'id': '9', 'type': 'attribute', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '18', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '23'], 'value': 'and'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'PY2'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '28', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}
|
Stolen completely from boto.providers
|
def _no_op(name, **kwargs):
return dict(name=name, result=True, changes={}, comment='')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_no_op'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '15', '18', '21']}; {'id': '12', 'type': 'keyword_argument', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '17', 'type': 'True', 'children': []}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'changes'}; {'id': '20', 'type': 'dictionary', 'children': []}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '23', 'type': 'string', 'children': [], 'value': "''"}
|
No-op state to support state config via the stateconf renderer.
|
def bootstrap(self, config):
pg_hba = config.get('pg_hba', [])
method = config.get('method') or 'initdb'
self._running_custom_bootstrap = method != 'initdb' and method in config and 'command' in config[method]
if self._running_custom_bootstrap:
do_initialize = self._custom_bootstrap
config = config[method]
else:
do_initialize = self._initdb
return do_initialize(config) and self.append_pg_hba(pg_hba) and self.save_configuration_files() \
and self._configure_server_parameters() and self.start()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bootstrap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '28', '46', '71']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pg_hba'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'pg_hba'"}; {'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': 'method'}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '27'], 'value': 'or'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'method'"}; {'id': '27', 'type': 'string', 'children': [], 'value': "'initdb'"}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_running_custom_bootstrap'}; {'id': '33', 'type': 'boolean_operator', 'children': ['34', '41'], 'value': 'and'}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '38'], 'value': 'and'}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': '!='}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'initdb'"}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': 'in'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': 'in'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'command'"}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50', '63']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_running_custom_bootstrap'}; {'id': '50', 'type': 'block', 'children': ['51', '57']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'do_initialize'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_custom_bootstrap'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '63', 'type': 'else_clause', 'children': ['64']}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'do_initialize'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_initdb'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'boolean_operator', 'children': ['73', '97'], 'value': 'and'}; {'id': '73', 'type': 'boolean_operator', 'children': ['74', '91', '92'], 'value': 'and'}; {'id': '74', 'type': 'boolean_operator', 'children': ['75', '86'], 'value': 'and'}; {'id': '75', 'type': 'boolean_operator', 'children': ['76', '80'], 'value': 'and'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'do_initialize'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'append_pg_hba'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'pg_hba'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'save_configuration_files'}; {'id': '90', 'type': 'argument_list', 'children': []}; {'id': '91', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '_configure_server_parameters'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'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': 'start'}; {'id': '101', 'type': 'argument_list', 'children': []}
|
Initialize a new node from scratch and start it.
|
def _construct_form(self, i, **kwargs):
if not settings.HIDE_LANGUAGE:
self._construct_available_languages()
form = super(TranslationFormSet, self)._construct_form(i, **kwargs)
if settings.HIDE_LANGUAGE:
form.instance.language_code = settings.DEFAULT_LANGUAGE
else:
language_code = form.instance.language_code
if language_code:
logger.debug(
u'Removing translation choice %s for instance %s'
u' in form %d', language_code, form.instance, i
)
self.available_languages.remove(language_code)
else:
initial_language_code = self._get_default_language()
logger.debug(
u'Preselecting language code %s for form %d',
initial_language_code, i
)
form.initial['language_code'] = initial_language_code
return form
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_construct_form'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '21', '36', '114']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '14']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'HIDE_LANGUAGE'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'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': '_construct_available_languages'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '24', 'type': 'call', 'children': ['25', '32']}; {'id': '25', 'type': 'attribute', 'children': ['26', '31']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'TranslationFormSet'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_construct_form'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '34', 'type': 'dictionary_splat', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40', '51']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'HIDE_LANGUAGE'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_LANGUAGE'}; {'id': '51', 'type': 'else_clause', 'children': ['52']}; {'id': '52', 'type': 'block', 'children': ['53', '61']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '63', '87']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '63', 'type': 'block', 'children': ['64', '78']}; {'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': 'logger'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '73', '74', '77']}; {'id': '70', 'type': 'concatenated_string', 'children': ['71', '72']}; {'id': '71', 'type': 'string', 'children': [], 'value': "u'Removing translation choice %s for instance %s'"}; {'id': '72', 'type': 'string', 'children': [], 'value': "u' in form %d'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'available_languages'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '87', 'type': 'else_clause', 'children': ['88']}; {'id': '88', 'type': 'block', 'children': ['89', '97', '106']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'initial_language_code'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '_get_default_language'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104', '105']}; {'id': '103', 'type': 'string', 'children': [], 'value': "u'Preselecting language code %s for form %d'"}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'initial_language_code'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '113']}; {'id': '108', 'type': 'subscript', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'initial'}; {'id': '112', 'type': 'string', 'children': [], 'value': "'language_code'"}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'initial_language_code'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'form'}
|
Construct the form, overriding the initial value for `language_code`.
|
def __isValidFilename(self, filename):
if filename and isinstance(filename, string_types):
if re.match(r'^[\w\d\_\-\.]+$', filename, re.I):
if self.__isValidTGZ(filename) or self.__isValidZIP(filename):
return True
return False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__isValidFilename'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'block', 'children': ['7', '45']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '10'], 'value': 'and'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'filename'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '27']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'string', 'children': [], 'value': "r'^[\\w\\d\\_\\-\\.]+$'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'I'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '42']}; {'id': '29', 'type': 'boolean_operator', 'children': ['30', '36'], 'value': 'or'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '__isValidTGZ'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '__isValidZIP'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'True', 'children': []}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'False', 'children': []}
|
Determine whether filename is valid
|
def _get_cache(self):
if not self._cache:
self._cache = get_cache(self.app)
return self._cache
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_cache'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '23']}; {'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': '_cache'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'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': '_cache'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_cache'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_cache'}
|
Return the cache to use for thundering herd protection, etc.
|
def remove_non_magic_cols(self):
for table_name in self.tables:
table = self.tables[table_name]
table.remove_non_magic_cols_from_table()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_non_magic_cols'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'table_name'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '11', 'type': 'block', 'children': ['12', '20']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '15', 'type': 'subscript', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'table_name'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'remove_non_magic_cols_from_table'}; {'id': '25', 'type': 'argument_list', 'children': []}
|
Remove all non-MagIC columns from all tables.
|
def AddLabels(self, labels_names, owner=None):
if owner is None and not self.token:
raise ValueError("Can't set label: No owner specified and "
"no access token available.")
if isinstance(labels_names, string_types):
raise ValueError("Label list can't be string.")
owner = owner or self.token.username
current_labels = self.Get(self.Schema.LABELS, self.Schema.LABELS())
for label_name in labels_names:
label = rdf_aff4.AFF4ObjectLabel(
name=label_name, owner=owner, timestamp=rdfvalue.RDFDatetime.Now())
current_labels.AddLabel(label)
self.Set(current_labels)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'AddLabels'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'labels_names'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '27', '39', '49', '69', '103']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '19']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '15'], 'value': 'and'}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'raise_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'concatenated_string', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"Can\'t set label: No owner specified and "'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"no access token available."'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '33']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'labels_names'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'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': 'ValueError'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"Label list can\'t be string."'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '42', 'type': 'boolean_operator', 'children': ['43', '44'], 'value': 'or'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'current_labels'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'Get'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'Schema'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'LABELS'}; {'id': '62', 'type': 'call', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Schema'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'LABELS'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'for_statement', 'children': ['70', '71', '72']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'label_name'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'labels_names'}; {'id': '72', 'type': 'block', 'children': ['73', '96']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'rdf_aff4'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'AFF4ObjectLabel'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '84', '87']}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'label_name'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '89', 'type': 'call', 'children': ['90', '95']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'rdfvalue'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'RDFDatetime'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'Now'}; {'id': '95', 'type': 'argument_list', 'children': []}; {'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': 'current_labels'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'AddLabel'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'label'}; {'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': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'Set'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'current_labels'}
|
Add labels to the AFF4Object.
|
def _default_capacity(self, value):
if value is not None:
return value
if self.default_return_capacity or self.rate_limiters:
return INDEXES
return NONE
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_default_capacity'}; {'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', '14', '25']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is not'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '22']}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '19'], 'value': 'or'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'default_return_capacity'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rate_limiters'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'INDEXES'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'NONE'}
|
Get the value for ReturnConsumedCapacity from provided value
|
def run_to_states(self):
self.execution_engine_lock.acquire()
return_value = self._run_to_states
self.execution_engine_lock.release()
return return_value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_to_states'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '20', '28']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'execution_engine_lock'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'acquire'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'return_value'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_run_to_states'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'execution_engine_lock'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'return_value'}
|
Property for the _run_to_states field
|
def main(host='localhost', port=8086):
now = datetime.datetime.today()
points = []
for angle in range(0, 360):
y = 10 + math.sin(math.radians(angle)) * 10
point = {
"measurement": 'foobar',
"time": int(now.strftime('%s')) + angle,
"fields": {
"value": y
}
}
points.append(point)
client = InfluxDBClient(host, port, USER, PASSWORD, DBNAME)
print("Create database: " + DBNAME)
client.create_database(DBNAME)
client.switch_database(DBNAME)
client.write_points(points)
time.sleep(3)
query = 'SELECT * FROM foobar'
print("Querying data: " + query)
result = client.query(query, database=DBNAME)
print("Result: {0}".format(result))
print("Delete database: " + DBNAME)
client.drop_database(DBNAME)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '6', 'type': 'string', 'children': [], 'value': "'localhost'"}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '8086'}; {'id': '10', 'type': 'block', 'children': ['11', '21', '25', '84', '95', '102', '109', '116', '123', '130', '134', '141', '153', '163', '170']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'now'}; {'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': 'datetime'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'points'}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '32']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '360'}; {'id': '32', 'type': 'block', 'children': ['33', '51', '77']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '+'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '50'], 'value': '*'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'radians'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'point'}; {'id': '54', 'type': 'dictionary', 'children': ['55', '58', '71']}; {'id': '55', 'type': 'pair', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': '"measurement"'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'foobar'"}; {'id': '58', 'type': 'pair', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': '"time"'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '70'], 'value': '+'}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'string', 'children': [], 'value': "'%s'"}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '71', 'type': 'pair', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': '"fields"'}; {'id': '73', 'type': 'dictionary', 'children': ['74']}; {'id': '74', 'type': 'pair', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'y'}; {'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': 'points'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'point'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'InfluxDBClient'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91', '92', '93', '94']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'USER'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'PASSWORD'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'DBNAME'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '+'}; {'id': '100', 'type': 'string', 'children': [], 'value': '"Create database: "'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'DBNAME'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'create_database'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'DBNAME'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'switch_database'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'DBNAME'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'write_points'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'points'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '133', 'type': 'string', 'children': [], 'value': "'SELECT * FROM foobar'"}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'binary_operator', 'children': ['139', '140'], 'value': '+'}; {'id': '139', 'type': 'string', 'children': [], 'value': '"Querying data: "'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '144', 'type': 'call', 'children': ['145', '148']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '148', 'type': 'argument_list', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '150', 'type': 'keyword_argument', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'DBNAME'}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'string', 'children': [], 'value': '"Result: {0}"'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}; {'id': '167', 'type': 'binary_operator', 'children': ['168', '169'], 'value': '+'}; {'id': '168', 'type': 'string', 'children': [], 'value': '"Delete database: "'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'DBNAME'}; {'id': '170', 'type': 'expression_statement', 'children': ['171']}; {'id': '171', 'type': 'call', 'children': ['172', '175']}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'drop_database'}; {'id': '175', 'type': 'argument_list', 'children': ['176']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'DBNAME'}
|
Define function to generate the sin wave.
|
def list_contributors(self, project_id=None, language_code=None):
data = self._run(
url_path="contributors/list",
id=project_id,
language=language_code
)
return data['result'].get('contributors', [])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_contributors'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '29']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'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': '_run'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23', '26']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'url_path'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"contributors/list"'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'language_code'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'result'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'contributors'"}; {'id': '38', 'type': 'list', 'children': [], 'value': '[]'}
|
Returns the list of contributors
|
def parse_list(self):
try:
return List([self.parse() for _ in
self.collect_tokens_until('CLOSE_BRACKET')])
except IncompatibleItemType as exc:
raise self.error(f'Item {str(exc.item)!r} is not a '
f'{exc.subtype.__name__} tag') from None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '26']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'list_comprehension', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'for_in_clause', 'children': ['19', '20']}; {'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': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'collect_tokens_until'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'CLOSE_BRACKET'"}; {'id': '26', 'type': 'except_clause', 'children': ['27', '31']}; {'id': '27', 'type': 'as_pattern', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'IncompatibleItemType'}; {'id': '29', 'type': 'as_pattern_target', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'raise_statement', 'children': ['33', '41']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'concatenated_string', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "f'Item {str(exc.item)!r} is not a '"}; {'id': '40', 'type': 'string', 'children': [], 'value': "f'{exc.subtype.__name__} tag'"}; {'id': '41', 'type': 'None', 'children': []}
|
Parse a list from the token stream.
|
def parse_metrics(self, f):
headers = None
for l in f['f'].splitlines():
s = l.strip().split("\t")
if headers is None:
headers = s
else:
s_name = s[ headers.index('Sample') ]
data = dict()
for idx, h in enumerate(headers):
try:
data[h] = float(s[idx])
except ValueError:
data[h] = s[idx]
self.rna_seqc_metrics[s_name] = data
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_metrics'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '6', 'type': 'block', 'children': ['7', '11']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '20']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'l'}; {'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': 'f'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'f'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '34']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'call', 'children': ['25', '32']}; {'id': '25', 'type': 'attribute', 'children': ['26', '31']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"\\t"'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38', '43']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'is'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '43', 'type': 'else_clause', 'children': ['44']}; {'id': '44', 'type': 'block', 'children': ['45', '56', '62', '95']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 's_name'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'Sample'"}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'for_statement', 'children': ['63', '66', '70']}; {'id': '63', 'type': 'pattern_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'try_statement', 'children': ['72', '84']}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '84', 'type': 'except_clause', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '92']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '102']}; {'id': '97', 'type': 'subscript', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'rna_seqc_metrics'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 's_name'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'data'}
|
Parse the metrics.tsv file from RNA-SeQC
|
def do_verify(marfile, keyfiles=None):
try:
with open(marfile, 'rb') as f:
with MarReader(f) as m:
errors = m.get_errors()
if errors:
print("File is not well formed: {}".format(errors))
sys.exit(1)
if keyfiles:
try:
keys = get_keys(keyfiles, m.signature_type)
except ValueError as e:
print(e)
sys.exit(1)
if any(m.verify(key) for key in keys):
print("Verification OK")
return True
else:
print("Verification failed")
sys.exit(1)
else:
print("Verification OK")
return True
except Exception as e:
print("Error opening or parsing file: {}".format(e))
sys.exit(1)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_verify'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'marfile'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'keyfiles'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'try_statement', 'children': ['10', '139']}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'with_statement', 'children': ['12', '22']}; {'id': '12', 'type': 'with_clause', 'children': ['13']}; {'id': '13', 'type': 'with_item', 'children': ['14']}; {'id': '14', 'type': 'as_pattern', 'children': ['15', '20']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'marfile'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '20', 'type': 'as_pattern_target', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'with_statement', 'children': ['24', '33']}; {'id': '24', 'type': 'with_clause', 'children': ['25']}; {'id': '25', 'type': 'with_item', 'children': ['26']}; {'id': '26', 'type': 'as_pattern', 'children': ['27', '31']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'MarReader'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '31', 'type': 'as_pattern_target', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '33', 'type': 'block', 'children': ['34', '42', '62']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get_errors'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'if_statement', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '44', 'type': 'block', 'children': ['45', '55']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"File is not well formed: {}"'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'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': 'sys'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'if_statement', 'children': ['63', '64', '130']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'keyfiles'}; {'id': '64', 'type': 'block', 'children': ['65', '95']}; {'id': '65', 'type': 'try_statement', 'children': ['66', '77']}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'get_keys'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'keyfiles'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'signature_type'}; {'id': '77', 'type': 'except_clause', 'children': ['78', '82']}; {'id': '78', 'type': 'as_pattern', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '80', 'type': 'as_pattern_target', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '82', 'type': 'block', 'children': ['83', '88']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'e'}; {'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': 'sys'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '95', 'type': 'if_statement', 'children': ['96', '108', '116']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '98', 'type': 'generator_expression', 'children': ['99', '105']}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'verify'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '105', 'type': 'for_in_clause', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '108', 'type': 'block', 'children': ['109', '114']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'string', 'children': [], 'value': '"Verification OK"'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'True', 'children': []}; {'id': '116', 'type': 'else_clause', 'children': ['117']}; {'id': '117', 'type': 'block', 'children': ['118', '123']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'string', 'children': [], 'value': '"Verification failed"'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '130', 'type': 'else_clause', 'children': ['131']}; {'id': '131', 'type': 'block', 'children': ['132', '137']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'string', 'children': [], 'value': '"Verification OK"'}; {'id': '137', 'type': 'return_statement', 'children': ['138']}; {'id': '138', 'type': 'True', 'children': []}; {'id': '139', 'type': 'except_clause', 'children': ['140', '144']}; {'id': '140', 'type': 'as_pattern', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '142', 'type': 'as_pattern_target', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '144', 'type': 'block', 'children': ['145', '155']}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '148', 'type': 'argument_list', 'children': ['149']}; {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'string', 'children': [], 'value': '"Error opening or parsing file: {}"'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'call', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'integer', 'children': [], 'value': '1'}
|
Verify the MAR file.
|
def environment_session_entity_type_path(cls, project, environment, user,
session, entity_type):
return google.api_core.path_template.expand(
'projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type}',
project=project,
environment=environment,
user=user,
session=session,
entity_type=entity_type,
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'environment_session_entity_type_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'entity_type'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '20']}; {'id': '13', 'type': 'attribute', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'google'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'api_core'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path_template'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'expand'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '25', '28', '31', '34']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type}'"}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'entity_type'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'entity_type'}
|
Return a fully-qualified environment_session_entity_type string.
|
def jflatten(j):
nobs, nf, nargs = j.shape
nrows, ncols = nf * nobs, nargs * nobs
jflat = np.zeros((nrows, ncols))
for n in xrange(nobs):
r, c = n * nf, n * nargs
jflat[r:(r + nf), c:(c + nargs)] = j[n]
return jflat
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'jflatten'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '27', '38', '78']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '12']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'nobs'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'nf'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'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': 'nrows'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ncols'}; {'id': '20', 'type': 'expression_list', 'children': ['21', '24']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '*'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'nf'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'nobs'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '*'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'nobs'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'jflat'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'tuple', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'nrows'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ncols'}; {'id': '38', 'type': 'for_statement', 'children': ['39', '40', '44']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'nobs'}; {'id': '44', 'type': 'block', 'children': ['45', '57']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'pattern_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '50', 'type': 'expression_list', 'children': ['51', '54']}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '*'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'nf'}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '*'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '75']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61', '68']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'jflat'}; {'id': '61', 'type': 'slice', 'children': ['62', '63', '64']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '63', 'type': 'colon', 'children': []}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '+'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'nf'}; {'id': '68', 'type': 'slice', 'children': ['69', '70', '71']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '70', 'type': 'colon', 'children': []}; {'id': '71', 'type': '()', 'children': ['72']}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '74'], 'value': '+'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'nargs'}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'jflat'}
|
Flatten 3_D Jacobian into 2-D.
|
def float16(val):
frac = val & 0x03ff
exp = (val >> 10) & 0x1F
sign = val >> 15
if exp:
value = 2 ** (exp - 16) * (1 + float(frac) / 2**10)
else:
value = float(frac) / 2**9
if sign:
value *= -1
return value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'float16'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '21', '27', '64', '72']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'frac'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '11'], 'value': '&'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0x03ff'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'exp'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '20'], 'value': '&'}; {'id': '16', 'type': '()', 'children': ['17']}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '19'], 'value': '>>'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0x1F'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sign'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '>>'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '15'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '29', '51']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'exp'}; {'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': 'value'}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '40'], 'value': '*'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '**'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '36', 'type': '()', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '-'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'exp'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '+'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '48'], 'value': '/'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'frac'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '**'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '51', 'type': 'else_clause', 'children': ['52']}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '61'], 'value': '/'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'frac'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '**'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sign'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'augmented_assignment', 'children': ['69', '70'], 'value': '*='}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '70', 'type': 'unary_operator', 'children': ['71'], 'value': '-'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Convert a 16-bit floating point value to a standard Python float.
|
def getTimes(dataTasks):
global begin_time
start_time, end_time = float('inf'), 0
for fichier, vals in dataTask.items():
try:
if hasattr(vals, 'values'):
tmp_start_time = min([a['start_time'] for a in vals.values()])[0]
if tmp_start_time < start_time:
start_time = tmp_start_time
tmp_end_time = max([a['end_time'] for a in vals.values()])[0]
if tmp_end_time > end_time:
end_time = tmp_end_time
except ValueError:
continue
begin_time = 1000 * start_time
return 1000 * start_time, 1000 * end_time
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getTimes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dataTasks'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '19', '98', '104']}; {'id': '6', 'type': 'global_statement', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'begin_time'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '13', 'type': 'expression_list', 'children': ['14', '18']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'inf'"}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '23', '28']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fichier'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dataTask'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'try_statement', 'children': ['30', '94']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'values'"}; {'id': '37', 'type': 'block', 'children': ['38', '57', '66', '85']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tmp_start_time'}; {'id': '41', 'type': 'subscript', 'children': ['42', '56']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'list_comprehension', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'start_time'"}; {'id': '49', 'type': 'for_in_clause', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': '<'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'tmp_start_time'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'tmp_start_time'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'tmp_end_time'}; {'id': '69', 'type': 'subscript', 'children': ['70', '84']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'list_comprehension', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'end_time'"}; {'id': '77', 'type': 'for_in_clause', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'vals'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '85', 'type': 'if_statement', 'children': ['86', '89']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '88'], 'value': '>'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'tmp_end_time'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'tmp_end_time'}; {'id': '94', 'type': 'except_clause', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'continue_statement', 'children': []}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'begin_time'}; {'id': '101', 'type': 'binary_operator', 'children': ['102', '103'], 'value': '*'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'expression_list', 'children': ['106', '109']}; {'id': '106', 'type': 'binary_operator', 'children': ['107', '108'], 'value': '*'}; {'id': '107', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '109', 'type': 'binary_operator', 'children': ['110', '111'], 'value': '*'}; {'id': '110', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'end_time'}
|
Get the start time and the end time of data in milliseconds
|
def zDDEClose(self):
if _PyZDDE.server and not _PyZDDE.liveCh:
_PyZDDE.server.Shutdown(self.conversation)
_PyZDDE.server = 0
elif _PyZDDE.server and self.connection and _PyZDDE.liveCh == 1:
_PyZDDE.server.Shutdown(self.conversation)
self.connection = False
self.appName = ''
_PyZDDE.liveCh -= 1
_PyZDDE.server = 0
elif self.connection:
_PyZDDE.server.Shutdown(self.conversation)
self.connection = False
self.appName = ''
_PyZDDE.liveCh -= 1
return 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zDDEClose'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '117']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15', '33', '83']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '11'], 'value': 'and'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '11', 'type': 'not_operator', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'liveCh'}; {'id': '15', 'type': 'block', 'children': ['16', '27']}; {'id': '16', 'type': 'expression_statement', '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': '_PyZDDE'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Shutdown'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'conversation'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'elif_clause', 'children': ['34', '47']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '42'], 'value': 'and'}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '39'], 'value': 'and'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '46'], 'value': '=='}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'liveCh'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'block', 'children': ['48', '59', '65', '71', '77']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'Shutdown'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'conversation'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '64', 'type': 'False', 'children': []}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'appName'}; {'id': '70', 'type': 'string', 'children': [], 'value': "''"}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'augmented_assignment', 'children': ['73', '76'], 'value': '-='}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'liveCh'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '83', 'type': 'elif_clause', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '87', 'type': 'block', 'children': ['88', '99', '105', '111']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '95']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'Shutdown'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'conversation'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '104', 'type': 'False', 'children': []}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'appName'}; {'id': '110', 'type': 'string', 'children': [], 'value': "''"}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'augmented_assignment', 'children': ['113', '116'], 'value': '-='}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_PyZDDE'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'liveCh'}; {'id': '116', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '117', 'type': 'return_statement', 'children': ['118']}; {'id': '118', 'type': 'integer', 'children': [], 'value': '0'}
|
Close the DDE link with Zemax server
|
def open(safe_file):
if os.path.isdir(safe_file) or os.path.isfile(safe_file):
return SentinelDataSet(safe_file)
else:
raise IOError("file not found: %s" % safe_file)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'safe_file'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '24', '30']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '16'], 'value': 'or'}; {'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': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'safe_file'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'safe_file'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'SentinelDataSet'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'safe_file'}; {'id': '30', 'type': 'else_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'raise_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '%'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"file not found: %s"'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'safe_file'}
|
Return a SentinelDataSet object.
|
def getLocalDateAndTime(date, time, *args, **kwargs):
localDt = getLocalDatetime(date, time, *args, **kwargs)
if time is not None:
return (localDt.date(), localDt.timetz())
else:
return (localDt.date(), None)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getLocalDateAndTime'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '23']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'localDt'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'getLocalDatetime'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19', '21']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '19', 'type': 'list_splat', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '21', 'type': 'dictionary_splat', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '27', '40']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'is not'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'tuple', 'children': ['30', '35']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'localDt'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'localDt'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'timetz'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'tuple', 'children': ['44', '49']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'localDt'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'None', 'children': []}
|
Get the date and time in the local timezone from date and optionally time
|
def run(self):
input = self._consume()
put_item = self._que_out.put
try:
if input is None:
res = self._callable(*self._args, **self._kwargs)
else:
res = self._callable(input, *self._args, **self._kwargs)
if res != None:
for item in res:
put_item(item)
except Exception as e:
self._que_err.put((self.name, e))
if input is not None:
for i in input:
pass
raise
finally:
for i in range(self._num_followers):
put_item(EXIT)
self._que_err.put(EXIT)
|
{'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', '14', '22']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'input'}; {'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': '_consume'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'put_item'}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_que_out'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '22', 'type': 'try_statement', 'children': ['23', '78', '108']}; {'id': '23', 'type': 'block', 'children': ['24', '64']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28', '45']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'is'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_callable'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '41']}; {'id': '37', 'type': 'list_splat', 'children': ['38']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_args'}; {'id': '41', 'type': 'dictionary_splat', 'children': ['42']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_kwargs'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'res'}; {'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': '_callable'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56', '60']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '56', 'type': 'list_splat', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_args'}; {'id': '60', 'type': 'dictionary_splat', 'children': ['61']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_kwargs'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '68']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': '!='}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '67', 'type': 'None', 'children': []}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'for_statement', 'children': ['70', '71', '72']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'put_item'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '78', 'type': 'except_clause', 'children': ['79', '83']}; {'id': '79', 'type': 'as_pattern', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '81', 'type': 'as_pattern_target', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '83', 'type': 'block', 'children': ['84', '97', '107']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '91']}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_que_err'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'tuple', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '97', 'type': 'if_statement', 'children': ['98', '101']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': 'is not'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '100', 'type': 'None', 'children': []}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'for_statement', 'children': ['103', '104', '105']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'pass_statement', 'children': []}; {'id': '107', 'type': 'raise_statement', 'children': []}; {'id': '108', 'type': 'finally_clause', 'children': ['109']}; {'id': '109', 'type': 'block', 'children': ['110', '124']}; {'id': '110', 'type': 'for_statement', 'children': ['111', '112', '118']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '112', 'type': 'call', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': '_num_followers'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'put_item'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'EXIT'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '131']}; {'id': '126', 'type': 'attribute', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': '_que_err'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'EXIT'}
|
Execute the task on all the input and send the needed number of EXIT at the end
|
def swap(self, c2):
inv = False
c1 = self
if c1.order > c2.order:
ct = c1
c1 = c2
c2 = ct
inv = True
return inv, c1, c2
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'swap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'c2'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '15', '40']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'inv'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'c1'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '23']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': '>'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'c1'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'c2'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '23', 'type': 'block', 'children': ['24', '28', '32', '36']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'c1'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'c1'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'c2'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'c2'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'inv'}; {'id': '39', 'type': 'True', 'children': []}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'expression_list', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'inv'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'c1'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'c2'}
|
put the order of currencies as market standard
|
def update(self, instance):
assert isinstance(instance, UnitOfWork)
if instance.db_id:
query = {'_id': ObjectId(instance.db_id)}
else:
query = {unit_of_work.PROCESS_NAME: instance.process_name,
unit_of_work.TIMEPERIOD: instance.timeperiod,
unit_of_work.START_ID: instance.start_id,
unit_of_work.END_ID: instance.end_id}
self.ds.update(COLLECTION_UNIT_OF_WORK, query, instance)
return instance.db_id
|
{'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': 'instance'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '64', '75']}; {'id': '7', 'type': 'assert_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'UnitOfWork'}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17', '30']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'db_id'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '21', 'type': 'dictionary', 'children': ['22']}; {'id': '22', 'type': 'pair', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'_id'"}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ObjectId'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'db_id'}; {'id': '30', 'type': 'else_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '35', 'type': 'dictionary', 'children': ['36', '43', '50', '57']}; {'id': '36', 'type': 'pair', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'unit_of_work'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'PROCESS_NAME'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'process_name'}; {'id': '43', 'type': 'pair', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'unit_of_work'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'TIMEPERIOD'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'timeperiod'}; {'id': '50', 'type': 'pair', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'unit_of_work'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'START_ID'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'start_id'}; {'id': '57', 'type': 'pair', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'unit_of_work'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'END_ID'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'end_id'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ds'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73', '74']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'COLLECTION_UNIT_OF_WORK'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'db_id'}
|
method finds unit_of_work record and change its status
|
def parse_table_name(self, table):
if "." in table:
schema, table = table.split(".")
else:
schema = None
return (schema, table)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_table_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '6', 'type': 'block', 'children': ['7', '29']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11', '23']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'in'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'pattern_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'tuple', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'table'}
|
Parse schema qualified table name
|
def fetch(cls, client, _id, symbol):
url = "https://api.robinhood.com/options/chains/"
params = {
"equity_instrument_ids": _id,
"state": "active",
"tradability": "tradable"
}
data = client.get(url, params=params)
def filter_func(x):
return x["symbol"] == symbol
results = list(filter(filter_func, data["results"]))
return results[0]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': '_id'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '8', 'type': 'block', 'children': ['9', '13', '26', '38', '49', '62']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"https://api.robinhood.com/options/chains/"'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '16', 'type': 'dictionary', 'children': ['17', '20', '23']}; {'id': '17', 'type': 'pair', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"equity_instrument_ids"'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_id'}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"state"'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"active"'}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"tradability"'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"tradable"'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '38', 'type': 'function_definition', 'children': ['39', '40', '42']}; {'id': '39', 'type': 'function_name', 'children': [], 'value': 'filter_func'}; {'id': '40', 'type': 'parameters', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '48'], 'value': '=='}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '47', 'type': 'string', 'children': [], 'value': '"symbol"'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'results'}; {'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': 'filter'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'filter_func'}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"results"'}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}
|
fetch option chain for instrument
|
def result_consumed(self, task_id):
logger.debug('Sending result consumed message.')
data = {
'task_ids': task_id,
}
return self._perform_post_request(self.results_consumed_endpoint, data, self.token_header)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'result_consumed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'task_id'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '21']}; {'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': 'logger'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'Sending result consumed message.'"}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '17', 'type': 'dictionary', 'children': ['18']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'task_ids'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'task_id'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_perform_post_request'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30', '31']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'results_consumed_endpoint'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'token_header'}
|
Report the result as successfully consumed.
|
def previous_friday(dt):
if dt.weekday() == 5:
return dt - timedelta(1)
elif dt.weekday() == 6:
return dt - timedelta(2)
return dt
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'previous_friday'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '5', 'type': 'block', 'children': ['6', '38']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14', '22']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '13'], 'value': '=='}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'weekday'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '-'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '22', 'type': 'elif_clause', 'children': ['23', '30']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '29'], 'value': '=='}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'weekday'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '-'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dt'}
|
If holiday falls on Saturday or Sunday, use previous Friday instead.
|
def _density_seaborn_(self, label=None, style=None, opts=None):
try:
fig = sns.kdeplot(self.df[self.x], self.df[self.y])
fig = self._set_with_height(fig, opts)
return fig
except Exception as e:
self.err(e, self.density_,
"Can not draw density chart")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_density_seaborn_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'try_statement', 'children': ['16', '51']}; {'id': '16', 'type': 'block', 'children': ['17', '39', '49']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sns'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kdeplot'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '32']}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'subscript', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_set_with_height'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '51', 'type': 'except_clause', 'children': ['52', '56']}; {'id': '52', 'type': 'as_pattern', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '54', 'type': 'as_pattern_target', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64', '67']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'density_'}; {'id': '67', 'type': 'string', 'children': [], 'value': '"Can not draw density chart"'}
|
Returns a Seaborn density chart
|
def objc_type_encoding(self):
if not hasattr(self, '_objc_type_encoding'):
self._objc_type_encoding = \
conf.lib.clang_getDeclObjCTypeEncoding(self)
return self._objc_type_encoding
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'objc_type_encoding'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '28']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'_objc_type_encoding'"}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19', '20']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_objc_type_encoding'}; {'id': '19', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'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': 'conf'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'lib'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'clang_getDeclObjCTypeEncoding'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'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': '_objc_type_encoding'}
|
Return the Objective-C type encoding as a str.
|
def readTableFromDelimited(f, separator="\t"):
rowNames = []
columnNames = []
matrix = []
first = True
for line in f.readlines():
line = line.rstrip()
if len(line) == 0:
continue
row = line.split(separator)
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': 'readTableFromDelimited'}; {'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': 'separator'}; {'id': '7', 'type': 'string', 'children': [], 'value': '"\\t"'}; {'id': '8', 'type': 'block', 'children': ['9', '13', '17', '21', '25', '103']}; {'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', '32']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'readlines'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33', '41', '50', '59']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'if_statement', 'children': ['42', '48']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '47'], 'value': '=='}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'continue_statement', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'separator'}; {'id': '59', 'type': 'if_statement', 'children': ['60', '61', '74']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '61', 'type': 'block', 'children': ['62', '70']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'columnNames'}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '67', 'type': 'slice', 'children': ['68', '69']}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '69', 'type': 'colon', 'children': []}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '73', 'type': 'False', 'children': []}; {'id': '74', 'type': 'else_clause', 'children': ['75']}; {'id': '75', 'type': 'block', 'children': ['76', '85']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'rowNames'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'matrix'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'list_comprehension', 'children': ['92', '96']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '96', 'type': 'for_in_clause', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '100', 'type': 'slice', 'children': ['101', '102']}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'colon', 'children': []}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108', '109']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'rowNames'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'columnNames'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'matrix'}
|
Reads a table object from given plain delimited file.
|
def setup_runner(self):
runner = ApplicationRunner(
url=self.config['transport_host'],
realm=u'realm1',
extra={
'config': self.config,
'handlers': self.handlers,
}
)
return runner
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_runner'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '35']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'runner'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ApplicationRunner'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '19', '22']}; {'id': '12', 'type': 'keyword_argument', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '14', 'type': 'subscript', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'transport_host'"}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'realm'}; {'id': '21', 'type': 'string', 'children': [], 'value': "u'realm1'"}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '24', 'type': 'dictionary', 'children': ['25', '30']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'config'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'handlers'"}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'handlers'}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'runner'}
|
Setup instance of runner var
|
def send_to_address(recipient_address, amount, private_key,
blockchain_client=BlockchainInfoClient(), fee=STANDARD_FEE,
change_address=None):
signed_tx = make_send_to_address_tx(recipient_address, amount,
private_key, blockchain_client, fee=fee,
change_address=change_address)
response = broadcast_transaction(signed_tx, blockchain_client)
return response
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_to_address'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'recipient_address'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'amount'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'private_key'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'blockchain_client'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'BlockchainInfoClient'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'fee'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'STANDARD_FEE'}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'change_address'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19', '35', '43']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'signed_tx'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'make_send_to_address_tx'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '27', '28', '29', '32']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'recipient_address'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'amount'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'private_key'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'blockchain_client'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'fee'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fee'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'change_address'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'change_address'}; {'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', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'broadcast_transaction'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'signed_tx'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'blockchain_client'}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'response'}
|
Builds, signs, and dispatches a "send to address" transaction.
|
def event_return(events):
for event in events:
ret = event.get('data', False)
if ret:
returner(ret)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'event_return'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '9']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '9', 'type': 'block', 'children': ['10', '20']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '19', 'type': 'False', 'children': []}; {'id': '20', 'type': 'if_statement', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'returner'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ret'}
|
Return event data via SMTP
|
def create_client(access_token):
url = 'http://keycloak:8080/auth/admin/realms/dci-test/clients'
r = requests.post(url,
data=json.dumps(client_data),
headers=get_auth_headers(access_token))
if r.status_code in (201, 409):
print('Keycloak client dci created successfully.')
else:
raise Exception(
'Error while creating Keycloak client dci:\nstatus code %s\n'
'error: %s' % (r.status_code, r.content)
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_client'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'access_token'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '33']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '9', 'type': 'string', 'children': [], 'value': "'http://keycloak:8080/auth/admin/realms/dci-test/clients'"}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '27']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'client_data'}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get_auth_headers'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'access_token'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '41', '47']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '38'], 'value': 'in'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '38', 'type': 'tuple', 'children': ['39', '40']}; {'id': '39', 'type': 'integer', 'children': [], 'value': '201'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '409'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'Keycloak client dci created successfully.'"}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'raise_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '57'], 'value': '%'}; {'id': '54', 'type': 'concatenated_string', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'Error while creating Keycloak client dci:\\nstatus code %s\\n'"}; {'id': '56', 'type': 'string', 'children': [], 'value': "'error: %s'"}; {'id': '57', 'type': 'tuple', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'content'}
|
Create the dci client in the master realm.
|
def add_subparser(subparsers):
parser = subparsers.add_parser("version",
help="Export versions of used software to stdout or a file ")
parser.add_argument("--workdir", help="Directory export programs to in workdir/provenance/programs.txt",
default=None)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_subparser'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'subparsers'}; {'id': '5', 'type': 'block', 'children': ['6', '18']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'subparsers'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'add_parser'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"version"'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"Export versions of used software to stdout or a file "'}; {'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': 'parser'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25', '28']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"--workdir"'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"Directory export programs to in workdir/provenance/programs.txt"'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '30', 'type': 'None', 'children': []}
|
Add command line option for exporting version information.
|
def save_load(jid, clear_load, minions=None):
for returner_ in __opts__[CONFIG_KEY]:
_mminion().returners['{0}.save_load'.format(returner_)](jid, clear_load)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'jid'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'clear_load'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'minions'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '15']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'returner_'}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'CONFIG_KEY'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '30']}; {'id': '18', 'type': 'subscript', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_mminion'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'returners'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'{0}.save_load'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'returner_'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'jid'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'clear_load'}
|
Write load to all returners in multi_returner
|
def tilequeue_rawr_enqueue(cfg, args):
from tilequeue.stats import RawrTileEnqueueStatsHandler
from tilequeue.rawr import make_rawr_enqueuer_from_cfg
msg_marshall_yaml = cfg.yml.get('message-marshall')
assert msg_marshall_yaml, 'Missing message-marshall config'
msg_marshaller = make_message_marshaller(msg_marshall_yaml)
logger = make_logger(cfg, 'rawr_enqueue')
stats = make_statsd_client_from_cfg(cfg)
stats_handler = RawrTileEnqueueStatsHandler(stats)
rawr_enqueuer = make_rawr_enqueuer_from_cfg(
cfg, logger, stats_handler, msg_marshaller)
with open(args.expiry_path) as fh:
coords = create_coords_generator_from_tiles_file(fh)
rawr_enqueuer(coords)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tilequeue_rawr_enqueue'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '30', '33', '40', '48', '55', '62', '72']}; {'id': '7', 'type': 'import_from_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'dotted_name', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'tilequeue'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '11', 'type': 'dotted_name', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'RawrTileEnqueueStatsHandler'}; {'id': '13', 'type': 'import_from_statement', 'children': ['14', '17']}; {'id': '14', 'type': 'dotted_name', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'tilequeue'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'rawr'}; {'id': '17', 'type': 'dotted_name', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'make_rawr_enqueuer_from_cfg'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'msg_marshall_yaml'}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'yml'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'message-marshall'"}; {'id': '30', 'type': 'assert_statement', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'msg_marshall_yaml'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'Missing message-marshall config'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'msg_marshaller'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'make_message_marshaller'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'msg_marshall_yaml'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'make_logger'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'rawr_enqueue'"}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'make_statsd_client_from_cfg'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'stats_handler'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'RawrTileEnqueueStatsHandler'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'rawr_enqueuer'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'make_rawr_enqueuer_from_cfg'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '70', '71']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'stats_handler'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'msg_marshaller'}; {'id': '72', 'type': 'with_statement', 'children': ['73', '84']}; {'id': '73', 'type': 'with_clause', 'children': ['74']}; {'id': '74', 'type': 'with_item', 'children': ['75']}; {'id': '75', 'type': 'as_pattern', 'children': ['76', '82']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'expiry_path'}; {'id': '82', 'type': 'as_pattern_target', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '84', 'type': 'block', 'children': ['85', '92']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'coords'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'create_coords_generator_from_tiles_file'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'rawr_enqueuer'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'coords'}
|
command to take tile expiry path and enqueue for rawr tile generation
|
def add(self, piece_uid, index):
if self.occupancy[index]:
raise OccupiedPosition
if self.exposed_territory[index]:
raise VulnerablePosition
klass = PIECE_CLASSES[piece_uid]
piece = klass(self, index)
territory = piece.territory
for i in self.indexes:
if self.occupancy[i] and territory[i]:
raise AttackablePiece
self.pieces.add(piece)
self.occupancy[index] = True
self.exposed_territory = list(
map(or_, self.exposed_territory, territory))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'piece_uid'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '26', '32', '40', '46', '65', '74', '82']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'subscript', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'occupancy'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'OccupiedPosition'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'exposed_territory'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'raise_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'VulnerablePosition'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'PIECE_CLASSES'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'piece_uid'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'piece'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'territory'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'piece'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'territory'}; {'id': '46', 'type': 'for_statement', 'children': ['47', '48', '51']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'indexes'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'if_statement', 'children': ['53', '62']}; {'id': '53', 'type': 'boolean_operator', 'children': ['54', '59'], 'value': 'and'}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'occupancy'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'territory'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'raise_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'AttackablePiece'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '72']}; {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pieces'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'piece'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '81']}; {'id': '76', 'type': 'subscript', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'occupancy'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '81', 'type': 'True', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'exposed_territory'}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94', '97']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'or_'}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'exposed_territory'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'territory'}
|
Add a piece to the board at the provided linear position.
|
def shell(no_ipython):
banner = "Interactive Werkzeug Shell"
namespace = make_shell()
if not no_ipython:
try:
try:
from IPython.frontend.terminal.embed import InteractiveShellEmbed
sh = InteractiveShellEmbed.instance(banner1=banner)
except ImportError:
from IPython.Shell import IPShellEmbed
sh = IPShellEmbed(banner=banner)
except ImportError:
pass
else:
sh(local_ns=namespace)
return
from code import interact
interact(banner, local=namespace)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shell'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'no_ipython'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '16', '75', '80']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'banner'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"Interactive Werkzeug Shell"'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'make_shell'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '19']}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'no_ipython'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'try_statement', 'children': ['21', '61', '65']}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'try_statement', 'children': ['23', '43']}; {'id': '23', 'type': 'block', 'children': ['24', '32']}; {'id': '24', 'type': 'import_from_statement', 'children': ['25', '30']}; {'id': '25', 'type': 'dotted_name', 'children': ['26', '27', '28', '29']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'IPython'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'frontend'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'terminal'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'embed'}; {'id': '30', 'type': 'dotted_name', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'InteractiveShellEmbed'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'sh'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'InteractiveShellEmbed'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'banner1'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'banner'}; {'id': '43', 'type': 'except_clause', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '45', 'type': 'block', 'children': ['46', '52']}; {'id': '46', 'type': 'import_from_statement', 'children': ['47', '50']}; {'id': '47', 'type': 'dotted_name', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'IPython'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Shell'}; {'id': '50', 'type': 'dotted_name', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'IPShellEmbed'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sh'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'IPShellEmbed'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'banner'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'banner'}; {'id': '61', 'type': 'except_clause', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'pass_statement', 'children': []}; {'id': '65', 'type': 'else_clause', 'children': ['66']}; {'id': '66', 'type': 'block', 'children': ['67', '74']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'sh'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'local_ns'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '74', 'type': 'return_statement', 'children': []}; {'id': '75', 'type': 'import_from_statement', 'children': ['76', '78']}; {'id': '76', 'type': 'dotted_name', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '78', 'type': 'dotted_name', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'interact'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'interact'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'banner'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'namespace'}
|
Start a new interactive python session.
|
def artifact_cache_dir(self):
return (self.get_options().artifact_cache_dir or
os.path.join(self.scratch_dir, 'artifacts'))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'artifact_cache_dir'}; {'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': '()', 'children': ['8']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '16'], 'value': 'or'}; {'id': '9', 'type': 'attribute', 'children': ['10', '15']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_options'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'artifact_cache_dir'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'scratch_dir'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'artifacts'"}
|
Note that this is unrelated to the general pants artifact cache.
|
def extended_blank_lines(logical_line,
blank_lines,
blank_before,
indent_level,
previous_logical):
if previous_logical.startswith('def '):
if blank_lines and pycodestyle.DOCSTRING_REGEX.match(logical_line):
yield (0, 'E303 too many blank lines ({0})'.format(blank_lines))
elif pycodestyle.DOCSTRING_REGEX.match(previous_logical):
if (
indent_level and
not blank_lines and
not blank_before and
logical_line.startswith(('def ')) and
'(self' in logical_line
):
yield (0, 'E301 expected 1 blank line, found 0')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extended_blank_lines'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'logical_line'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'blank_lines'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'blank_before'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'indent_level'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'previous_logical'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '17', '40']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'previous_logical'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'def '"}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '29']}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '21'], 'value': 'and'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'blank_lines'}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pycodestyle'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'DOCSTRING_REGEX'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'logical_line'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'yield', 'children': ['32']}; {'id': '32', 'type': 'tuple', 'children': ['33', '34']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'E303 too many blank lines ({0})'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'blank_lines'}; {'id': '40', 'type': 'elif_clause', 'children': ['41', '49']}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pycodestyle'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'DOCSTRING_REGEX'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'previous_logical'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'if_statement', 'children': ['51', '71']}; {'id': '51', 'type': '()', 'children': ['52']}; {'id': '52', 'type': 'boolean_operator', 'children': ['53', '68'], 'value': 'and'}; {'id': '53', 'type': 'boolean_operator', 'children': ['54', '61'], 'value': 'and'}; {'id': '54', 'type': 'boolean_operator', 'children': ['55', '59'], 'value': 'and'}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '57'], 'value': 'and'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'indent_level'}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'blank_lines'}; {'id': '59', 'type': 'not_operator', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'blank_before'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'logical_line'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': '()', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'def '"}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': 'in'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'(self'"}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'logical_line'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'yield', 'children': ['74']}; {'id': '74', 'type': 'tuple', 'children': ['75', '76']}; {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'E301 expected 1 blank line, found 0'"}
|
Check for missing blank lines after class declaration.
|
def load(self, **kwargs):
coordsys = kwargs.get('coordsys', 'CEL')
extdir = kwargs.get('extdir', self.extdir)
srcname = kwargs.get('srcname', None)
self.clear()
self.load_diffuse_srcs()
for c in self.config['catalogs']:
if isinstance(c, catalog.Catalog):
self.load_existing_catalog(c)
continue
extname = os.path.splitext(c)[1]
if extname != '.xml':
self.load_fits_catalog(c, extdir=extdir, coordsys=coordsys,
srcname=srcname)
elif extname == '.xml':
self.load_xml(c, extdir=extdir, coordsys=coordsys)
else:
raise Exception('Unrecognized catalog file extension: %s' % c)
for c in self.config['sources']:
if 'name' not in c:
raise Exception(
'No name field in source dictionary:\n ' + str(c))
self.create_source(c['name'], c, build_index=False)
self._build_src_index()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '30', '40', '46', '52', '138', '174']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'coordsys'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'coordsys'"}; {'id': '17', 'type': 'string', 'children': [], 'value': "'CEL'"}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'extdir'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'extdir'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'extdir'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'srcname'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'srcname'"}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'load_diffuse_srcs'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'for_statement', 'children': ['53', '54', '59']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'catalogs'"}; {'id': '59', 'type': 'block', 'children': ['60', '77', '90']}; {'id': '60', 'type': 'if_statement', 'children': ['61', '68']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'catalog'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'Catalog'}; {'id': '68', 'type': 'block', 'children': ['69', '76']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'load_existing_catalog'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '76', 'type': 'continue_statement', 'children': []}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'extname'}; {'id': '80', 'type': 'subscript', 'children': ['81', '89']}; {'id': '81', 'type': 'call', 'children': ['82', '87']}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'splitext'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '90', 'type': 'if_statement', 'children': ['91', '94', '111', '129']}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': '!='}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'extname'}; {'id': '93', 'type': 'string', 'children': [], 'value': "'.xml'"}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'load_fits_catalog'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '102', '105', '108']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'extdir'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'extdir'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'coordsys'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'coordsys'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'srcname'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'srcname'}; {'id': '111', 'type': 'elif_clause', 'children': ['112', '115']}; {'id': '112', 'type': 'comparison_operator', 'children': ['113', '114'], 'value': '=='}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'extname'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'.xml'"}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'load_xml'}; {'id': '121', 'type': 'argument_list', 'children': ['122', '123', '126']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '123', 'type': 'keyword_argument', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'extdir'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'extdir'}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'coordsys'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'coordsys'}; {'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': 'Exception'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'binary_operator', 'children': ['136', '137'], 'value': '%'}; {'id': '136', 'type': 'string', 'children': [], 'value': "'Unrecognized catalog file extension: %s'"}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '138', 'type': 'for_statement', 'children': ['139', '140', '145']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '140', 'type': 'subscript', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '144', 'type': 'string', 'children': [], 'value': "'sources'"}; {'id': '145', 'type': 'block', 'children': ['146', '161']}; {'id': '146', 'type': 'if_statement', 'children': ['147', '150']}; {'id': '147', 'type': 'comparison_operator', 'children': ['148', '149'], 'value': 'not in'}; {'id': '148', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '150', 'type': 'block', 'children': ['151']}; {'id': '151', 'type': 'raise_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'binary_operator', 'children': ['156', '157'], 'value': '+'}; {'id': '156', 'type': 'string', 'children': [], 'value': "'No name field in source dictionary:\\n '"}; {'id': '157', 'type': 'call', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '166']}; {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'create_source'}; {'id': '166', 'type': 'argument_list', 'children': ['167', '170', '171']}; {'id': '167', 'type': 'subscript', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '169', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '171', 'type': 'keyword_argument', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'build_index'}; {'id': '173', 'type': 'False', 'children': []}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}; {'id': '175', 'type': 'call', 'children': ['176', '179']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': '_build_src_index'}; {'id': '179', 'type': 'argument_list', 'children': []}
|
Load both point source and diffuse components.
|
def widen(self):
t, h = self.time, self.half_duration
h *= self.scaling_coeff_x
self.set_interval((t - h, t + h))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'widen'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '24']}; {'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': 't'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '11', 'type': 'expression_list', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'half_duration'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'augmented_assignment', 'children': ['20', '21'], 'value': '*='}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'scaling_coeff_x'}; {'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': 'set_interval'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'tuple', 'children': ['31', '34']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '-'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '+'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'h'}
|
Increase the interval size.
|
def start(ctx, **kwargs):
update_context(ctx, kwargs)
daemon = mk_daemon(ctx)
if ctx.debug or kwargs['no_fork']:
daemon.run()
else:
daemon.start()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '21']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'update_context'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'daemon'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'mk_daemon'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '29', '36']}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '26'], 'value': 'or'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'no_fork'"}; {'id': '29', 'type': 'block', 'children': ['30']}; {'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': 'daemon'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'daemon'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '43', 'type': 'argument_list', 'children': []}
|
start a vaping process
|
def update_params(params, updates):
params = params.copy() if isinstance(params, dict) else dict()
params.update(updates)
return params
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_params'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'updates'}; {'id': '6', 'type': 'block', 'children': ['7', '24', '31']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '10', 'type': 'conditional_expression', 'children': ['11', '16', '21'], 'value': 'if'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'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': 'params'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'updates'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'params'}
|
Merges updates into params
|
def to_prj(self, filename):
with open(filename, "w") as fp:
fp.write(self.prj)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_prj'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'as_pattern', 'children': ['11', '16']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"w"'}; {'id': '16', 'type': 'as_pattern_target', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'write'}; {'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': 'prj'}
|
Saves prj WKT to given file.
|
def aggregate_key(self, aggregate_key):
aggregation = self.data_dict[aggregate_key]
data_dict_keys = {y for x in aggregation for y in x.keys()}
for key in data_dict_keys:
stacked = np.stack([d[key] for d in aggregation], axis=0)
self.data_dict[key] = np.mean(stacked, axis=0)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aggregate_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'aggregate_key'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '30']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'aggregation'}; {'id': '10', 'type': 'subscript', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data_dict'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'aggregate_key'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'data_dict_keys'}; {'id': '18', 'type': 'set_comprehension', 'children': ['19', '20', '23']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'aggregation'}; {'id': '23', 'type': 'for_in_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'data_dict_keys'}; {'id': '33', 'type': 'block', 'children': ['34', '52']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'stacked'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'stack'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '49']}; {'id': '42', 'type': 'list_comprehension', 'children': ['43', '46']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '46', 'type': 'for_in_clause', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'aggregation'}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '59']}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'data_dict'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'stacked'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '0'}
|
Aggregate values from key and put them into the top-level dictionary
|
def create(cls, api, run_id=None, project=None, username=None):
run_id = run_id or util.generate_id()
project = project or api.settings.get("project")
mutation = gql(
)
variables = {'entity': username,
'project': project, 'name': run_id}
res = api.client.execute(mutation, variable_values=variables)
res = res['upsertBucket']['bucket']
return Run(api.client, res["project"]["entity"]["name"], res["project"]["name"], res["name"], {
"id": res["id"],
"config": "{}",
"systemMetrics": "{}",
"summaryMetrics": "{}",
"tags": [],
"description": None,
"state": "running"
})
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16', '26', '39', '45', '58', '72', '80']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '21'], 'value': 'or'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'generate_id'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '29', 'type': 'boolean_operator', 'children': ['30', '31'], 'value': 'or'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'project'}; {'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': 'api'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"project"'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'mutation'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'gql'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '48', 'type': 'dictionary', 'children': ['49', '52', '55']}; {'id': '49', 'type': 'pair', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'entity'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '52', 'type': 'pair', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'project'"}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '55', 'type': 'pair', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'res'}; {'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': 'api'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'mutation'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'variable_values'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'upsertBucket'"}; {'id': '79', 'type': 'string', 'children': [], 'value': "'bucket'"}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'Run'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '87', '94', '99', '102']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '87', 'type': 'subscript', 'children': ['88', '93']}; {'id': '88', 'type': 'subscript', 'children': ['89', '92']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '91', 'type': 'string', 'children': [], 'value': '"project"'}; {'id': '92', 'type': 'string', 'children': [], 'value': '"entity"'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '94', 'type': 'subscript', 'children': ['95', '98']}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '97', 'type': 'string', 'children': [], 'value': '"project"'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '102', 'type': 'dictionary', 'children': ['103', '108', '111', '114', '117', '120', '123']}; {'id': '103', 'type': 'pair', 'children': ['104', '105']}; {'id': '104', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '107', 'type': 'string', 'children': [], 'value': '"id"'}; {'id': '108', 'type': 'pair', 'children': ['109', '110']}; {'id': '109', 'type': 'string', 'children': [], 'value': '"config"'}; {'id': '110', 'type': 'string', 'children': [], 'value': '"{}"'}; {'id': '111', 'type': 'pair', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': '"systemMetrics"'}; {'id': '113', 'type': 'string', 'children': [], 'value': '"{}"'}; {'id': '114', 'type': 'pair', 'children': ['115', '116']}; {'id': '115', 'type': 'string', 'children': [], 'value': '"summaryMetrics"'}; {'id': '116', 'type': 'string', 'children': [], 'value': '"{}"'}; {'id': '117', 'type': 'pair', 'children': ['118', '119']}; {'id': '118', 'type': 'string', 'children': [], 'value': '"tags"'}; {'id': '119', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '120', 'type': 'pair', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': '"description"'}; {'id': '122', 'type': 'None', 'children': []}; {'id': '123', 'type': 'pair', 'children': ['124', '125']}; {'id': '124', 'type': 'string', 'children': [], 'value': '"state"'}; {'id': '125', 'type': 'string', 'children': [], 'value': '"running"'}
|
Create a run for the given project
|
def apply(funcs, stack):
return reduce(lambda x, y: y(x), funcs, stack)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'funcs'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'stack'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'reduce'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '19', '20']}; {'id': '11', 'type': 'lambda', 'children': ['12', '15']}; {'id': '12', 'type': 'lambda_parameters', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'funcs'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'stack'}
|
Apply functions to the stack, passing the resulting stack to next state.
|
def filter_by_domain(self, domain):
query = self._copy()
query.domain = domain
return query
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_by_domain'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '21']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'query'}; {'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': '_copy'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'query'}
|
Apply the given domain to a copy of this query
|
def flag_values_dict(self):
return {name: flag.value for name, flag in six.iteritems(self._flags())}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flag_values_dict'}; {'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': 'dictionary_comprehension', 'children': ['8', '13']}; {'id': '8', 'type': 'pair', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'for_in_clause', 'children': ['14', '17']}; {'id': '14', 'type': 'pattern_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_flags'}; {'id': '26', 'type': 'argument_list', 'children': []}
|
Returns a dictionary that maps flag names to flag values.
|
def _execution(self):
did_start_executing = False
if self.state == STATE_DEFAULT:
did_start_executing = True
self.state = STATE_EXECUTING
def close():
if did_start_executing and self.state == STATE_EXECUTING:
self.state = STATE_DEFAULT
yield close
close()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_execution'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '27', '46', '49']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'did_start_executing'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'if_statement', 'children': ['11', '16']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '15'], 'value': '=='}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'STATE_DEFAULT'}; {'id': '16', 'type': 'block', 'children': ['17', '21']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'did_start_executing'}; {'id': '20', 'type': 'True', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'STATE_EXECUTING'}; {'id': '27', 'type': 'function_definition', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '29', 'type': 'parameters', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'if_statement', 'children': ['32', '39']}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '34'], 'value': 'and'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'did_start_executing'}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '38'], 'value': '=='}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'STATE_EXECUTING'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'STATE_DEFAULT'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'yield', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '52', 'type': 'argument_list', 'children': []}
|
Context manager for executing some JavaScript inside a template.
|
def _spec(self, name):
"Return the named spec."
for s in self._framespec:
if s.name == name:
return s
raise ValueError("Unknown spec: " + name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_spec'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '24']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Return the named spec."'}; {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '14']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_framespec'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '21']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': '=='}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'raise_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '+'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"Unknown spec: "'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Return the named spec.
|
def create_secret(*args, **kwargs):
to_sign = '-!'.join(args) + '$$'.join(kwargs.values())
key = settings.SECRET_FOR_SIGNS
hashed = hmac.new(key, to_sign, sha1)
return re.sub(r'[\W_]+', '', binascii.b2a_base64(hashed.digest()))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_secret'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '29', '35', '46']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'to_sign'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '19'], 'value': '+'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'-!'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'$$'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'SECRET_FOR_SIGNS'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'hashed'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'hmac'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'to_sign'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sha1'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53', '54']}; {'id': '52', 'type': 'string', 'children': [], 'value': "r'[\\W_]+'"}; {'id': '53', 'type': 'string', 'children': [], 'value': "''"}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'binascii'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'b2a_base64'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'hashed'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'digest'}; {'id': '63', 'type': 'argument_list', 'children': []}
|
Return a secure key generated from the user and the object. As we load elements fron any class from user imput, this prevent the user to specify arbitrary class
|
def unfreeze_extensions(self):
output_path = os.path.join(_registry_folder(), 'frozen_extensions.json')
if not os.path.isfile(output_path):
raise ExternalError("There is no frozen extension list")
os.remove(output_path)
ComponentRegistry._frozen_extensions = None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unfreeze_extensions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '36', '43']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'output_path'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_registry_folder'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'string', 'children': [], 'value': "'frozen_extensions.json'"}; {'id': '20', 'type': 'if_statement', 'children': ['21', '30']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'output_path'}; {'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': 'ExternalError'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"There is no frozen extension list"'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'output_path'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ComponentRegistry'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_frozen_extensions'}; {'id': '48', 'type': 'None', 'children': []}
|
Remove a previously frozen list of extensions.
|
def scale_cb(self, setting, value):
zoomlevel = self.zoom.calc_level(value)
self.t_.set(zoomlevel=zoomlevel)
self.redraw(whence=0)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scale_cb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'setting'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '30']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'zoomlevel'}; {'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': 'zoom'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'calc_level'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'value'}; {'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': 't_'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'zoomlevel'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'zoomlevel'}; {'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': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'redraw'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'whence'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}
|
Handle callback related to image scaling.
|
def _keyring_equivalent(keyring_one, keyring_two):
def keyring_extract_key(file_path):
with open(file_path) as f:
for line in f:
content = line.strip()
if len(content) == 0:
continue
split_line = content.split('=')
if split_line[0].strip() == 'key':
return "=".join(split_line[1:]).strip()
raise RuntimeError("File '%s' is not a keyring" % file_path)
key_one = keyring_extract_key(keyring_one)
key_two = keyring_extract_key(keyring_two)
return key_one == key_two
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_keyring_equivalent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'keyring_one'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'keyring_two'}; {'id': '6', 'type': 'block', 'children': ['7', '86', '93', '100']}; {'id': '7', 'type': 'function_definition', 'children': ['8', '9', '11']}; {'id': '8', 'type': 'function_name', 'children': [], 'value': 'keyring_extract_key'}; {'id': '9', 'type': 'parameters', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '11', 'type': 'block', 'children': ['12', '79']}; {'id': '12', 'type': 'with_statement', 'children': ['13', '22']}; {'id': '13', 'type': 'with_clause', 'children': ['14']}; {'id': '14', 'type': 'with_item', 'children': ['15']}; {'id': '15', 'type': 'as_pattern', 'children': ['16', '20']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '20', 'type': 'as_pattern_target', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '26', 'type': 'block', 'children': ['27', '35', '44', '53']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '42']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '41'], 'value': '=='}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'continue_statement', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'split_line'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '53', 'type': 'if_statement', 'children': ['54', '63']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '62'], 'value': '=='}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'split_line'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'string', 'children': [], 'value': "'key'"}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '78']}; {'id': '66', 'type': 'attribute', 'children': ['67', '77']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': '"="'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'split_line'}; {'id': '74', 'type': 'slice', 'children': ['75', '76']}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'colon', 'children': []}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '78', 'type': 'argument_list', 'children': []}; {'id': '79', 'type': 'raise_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '%'}; {'id': '84', 'type': 'string', 'children': [], 'value': '"File \'%s\' is not a keyring"'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'key_one'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'keyring_extract_key'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'keyring_one'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'key_two'}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'keyring_extract_key'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'keyring_two'}; {'id': '100', 'type': 'return_statement', 'children': ['101']}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '103'], 'value': '=='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'key_one'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'key_two'}
|
Check two keyrings are identical
|
def objectsFromPEM(pemdata):
certificates = []
keys = []
blobs = [b""]
for line in pemdata.split(b"\n"):
if line.startswith(b'-----BEGIN'):
if b'CERTIFICATE' in line:
blobs = certificates
else:
blobs = keys
blobs.append(b'')
blobs[-1] += line
blobs[-1] += b'\n'
keys = [KeyPair.load(key, FILETYPE_PEM) for key in keys]
certificates = [Certificate.loadPEM(certificate)
for certificate in certificates]
return PEMObjects(keys=keys, certificates=certificates)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'objectsFromPEM'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pemdata'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '19', '72', '86', '99']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'certificates'}; {'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': 'keys'}; {'id': '13', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'blobs'}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': '[b""]'}; {'id': '18', 'type': 'string', 'children': [], 'value': 'b""'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '27']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pemdata'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': 'b"\\n"'}; {'id': '27', 'type': 'block', 'children': ['28', '58', '65']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '35']}; {'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': 'startswith'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "b'-----BEGIN'"}; {'id': '35', 'type': 'block', 'children': ['36', '51']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40', '45']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'in'}; {'id': '38', 'type': 'string', 'children': [], 'value': "b'CERTIFICATE'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'blobs'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'certificates'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'blobs'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'blobs'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': "b''"}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'augmented_assignment', 'children': ['60', '64'], 'value': '+='}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'blobs'}; {'id': '62', 'type': 'unary_operator', 'children': ['63'], 'value': '-'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'augmented_assignment', 'children': ['67', '71'], 'value': '+='}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'blobs'}; {'id': '69', 'type': 'unary_operator', 'children': ['70'], 'value': '-'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'string', 'children': [], 'value': "b'\\n'"}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '75', 'type': 'list_comprehension', 'children': ['76', '83']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'KeyPair'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'FILETYPE_PEM'}; {'id': '83', 'type': 'for_in_clause', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'certificates'}; {'id': '89', 'type': 'list_comprehension', 'children': ['90', '96']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'Certificate'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'loadPEM'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'certificate'}; {'id': '96', 'type': 'for_in_clause', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'certificate'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'certificates'}; {'id': '99', 'type': 'return_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'PEMObjects'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '106']}; {'id': '103', 'type': 'keyword_argument', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '106', 'type': 'keyword_argument', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'certificates'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'certificates'}
|
Load some objects from a PEM.
|
def dweet_for(thing_name, payload, key=None, session=None):
if key is not None:
params = {'key': key}
else:
params = None
return _send_dweet(payload, '/dweet/for/{0}'.format(thing_name), params=params, session=session)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dweet_for'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'thing_name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '31']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17', '25']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'is not'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '21', 'type': 'dictionary', 'children': ['22']}; {'id': '22', 'type': 'pair', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'key'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '25', 'type': 'else_clause', 'children': ['26']}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_send_dweet'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36', '42', '45']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'/dweet/for/{0}'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'thing_name'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'session'}
|
Send a dweet to dweet.io for a thing with a known name
|
def partition(molList, options):
status_field = options.status_field
active_label = options.active_label
decoy_label = options.decoy_label
activeList = []
decoyList = []
for mol in molList:
if mol.GetProp(status_field) == active_label:
activeList.append(mol)
elif mol.GetProp(status_field) == decoy_label:
decoyList.append(mol)
return activeList, decoyList
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'partition'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'molList'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '25', '29', '33', '71']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'status_field'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'status_field'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'active_label'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'active_label'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'decoy_label'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'decoy_label'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'activeList'}; {'id': '28', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'decoyList'}; {'id': '32', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'molList'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '46', '54']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '45'], 'value': '=='}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'GetProp'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'status_field'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'active_label'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'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': 'activeList'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '54', 'type': 'elif_clause', 'children': ['55', '63']}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '62'], 'value': '=='}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'GetProp'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'status_field'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'decoy_label'}; {'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': 'decoyList'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'expression_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'activeList'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'decoyList'}
|
Partition molList into activeList and decoyList
|
def cursor(self):
if self._cursor < 0:
self.cursor = 0
if self._cursor > len(self):
self.cursor = len(self)
return self._cursor
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cursor'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '38']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_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': '_cursor'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '28']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '24'], 'value': '>'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_cursor'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_cursor'}
|
The position of the cursor in the text.
|
def load_json_file_contents(path: str) -> str:
assert isinstance(path, str)
content = None
file_path = os.path.abspath(path)
content = fileutils.read_text_from_file(file_path)
json_object = json.loads(content)
content = json.dumps(json_object, sort_keys=True, indent=4)
return content
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_json_file_contents'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '10', 'type': 'block', 'children': ['11', '17', '21', '32', '41', '50', '65']}; {'id': '11', 'type': 'assert_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'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': 'abspath'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'fileutils'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'read_text_from_file'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'json_object'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59', '62']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'json_object'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'sort_keys'}; {'id': '61', 'type': 'True', 'children': []}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'content'}
|
Loads contents from a json file
|
def _no_primary(max_staleness, selection):
smax = selection.secondary_with_max_last_write_date()
if not smax:
return selection.with_server_descriptions([])
sds = []
for s in selection.server_descriptions:
if s.server_type == SERVER_TYPE.RSSecondary:
staleness = (smax.last_write_date -
s.last_write_date +
selection.heartbeat_frequency)
if staleness <= max_staleness:
sds.append(s)
else:
sds.append(s)
return selection.with_server_descriptions(sds)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_no_primary'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'max_staleness'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '26', '30', '81']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'smax'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'secondary_with_max_last_write_date'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'if_statement', 'children': ['16', '18']}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'smax'}; {'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': 'selection'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'with_server_descriptions'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sds'}; {'id': '29', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '35']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'server_descriptions'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '44', '72']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '41'], 'value': '=='}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'server_type'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'SERVER_TYPE'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'RSSecondary'}; {'id': '44', 'type': 'block', 'children': ['45', '60']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'staleness'}; {'id': '48', 'type': '()', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '57'], 'value': '+'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '54'], 'value': '-'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'smax'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'last_write_date'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'last_write_date'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'heartbeat_frequency'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '64']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '63'], 'value': '<='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'staleness'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'max_staleness'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'sds'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '72', 'type': 'else_clause', 'children': ['73']}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'sds'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '81', 'type': 'return_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'with_server_descriptions'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'sds'}
|
Apply max_staleness, in seconds, to a Selection with no known primary.
|
def experiment_list(args):
experiment_config = Experiments()
experiment_dict = experiment_config.get_all_experiments()
if not experiment_dict:
print('There is no experiment running...')
exit(1)
update_experiment()
experiment_id_list = []
if args.all and args.all == 'all':
for key in experiment_dict.keys():
experiment_id_list.append(key)
else:
for key in experiment_dict.keys():
if experiment_dict[key]['status'] != 'STOPPED':
experiment_id_list.append(key)
if not experiment_id_list:
print_warning('There is no experiment running...\nYou can use \'nnictl experiment list all\' to list all stopped experiments!')
experiment_information = ""
for key in experiment_id_list:
experiment_information += (EXPERIMENT_DETAIL_FORMAT % (key, experiment_dict[key]['status'], experiment_dict[key]['port'],\
experiment_dict[key].get('platform'), experiment_dict[key]['startTime'], experiment_dict[key]['endTime']))
print(EXPERIMENT_INFORMATION_FORMAT % experiment_information)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'experiment_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '20', '34', '38', '42', '103', '107', '148']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'experiment_config'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Experiments'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'experiment_config'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_all_experiments'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'if_statement', 'children': ['21', '23']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '23', 'type': 'block', 'children': ['24', '29']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'There is no experiment running...'"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'update_experiment'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'experiment_id_list'}; {'id': '41', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '52', '68']}; {'id': '43', 'type': 'boolean_operator', 'children': ['44', '47'], 'value': 'and'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '51'], 'value': '=='}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'all'"}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '60']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'experiment_id_list'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '68', 'type': 'else_clause', 'children': ['69']}; {'id': '69', 'type': 'block', 'children': ['70', '94']}; {'id': '70', 'type': 'for_statement', 'children': ['71', '72', '77']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '76', 'type': 'argument_list', 'children': []}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'if_statement', 'children': ['79', '86']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '85'], 'value': '!='}; {'id': '80', 'type': 'subscript', 'children': ['81', '84']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '84', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'STOPPED'"}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'experiment_id_list'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '94', 'type': 'if_statement', 'children': ['95', '97']}; {'id': '95', 'type': 'not_operator', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'experiment_id_list'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'print_warning'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'string', 'children': [], 'value': "'There is no experiment running...\\nYou can use \\'nnictl experiment list all\\' to list all stopped experiments!'"}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'experiment_information'}; {'id': '106', 'type': 'string', 'children': [], 'value': '""'}; {'id': '107', 'type': 'for_statement', 'children': ['108', '109', '110']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'experiment_id_list'}; {'id': '110', 'type': 'block', 'children': ['111']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'augmented_assignment', 'children': ['113', '114'], 'value': '+='}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'experiment_information'}; {'id': '114', 'type': '()', 'children': ['115']}; {'id': '115', 'type': 'binary_operator', 'children': ['116', '117'], 'value': '%'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'EXPERIMENT_DETAIL_FORMAT'}; {'id': '117', 'type': 'tuple', 'children': ['118', '119', '124', '129', '130', '138', '143']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '119', 'type': 'subscript', 'children': ['120', '123']}; {'id': '120', 'type': 'subscript', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '123', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '124', 'type': 'subscript', 'children': ['125', '128']}; {'id': '125', 'type': 'subscript', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '128', 'type': 'string', 'children': [], 'value': "'port'"}; {'id': '129', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '130', 'type': 'call', 'children': ['131', '136']}; {'id': '131', 'type': 'attribute', 'children': ['132', '135']}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'string', 'children': [], 'value': "'platform'"}; {'id': '138', 'type': 'subscript', 'children': ['139', '142']}; {'id': '139', 'type': 'subscript', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '142', 'type': 'string', 'children': [], 'value': "'startTime'"}; {'id': '143', 'type': 'subscript', 'children': ['144', '147']}; {'id': '144', 'type': 'subscript', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'experiment_dict'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '147', 'type': 'string', 'children': [], 'value': "'endTime'"}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'call', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '151', 'type': 'argument_list', 'children': ['152']}; {'id': '152', 'type': 'binary_operator', 'children': ['153', '154'], 'value': '%'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'EXPERIMENT_INFORMATION_FORMAT'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'experiment_information'}
|
get the information of all experiments
|
def _is_last_child(self, tagname, attributes=None):
children = self.cur_node.getchildren()
if children:
result = self._is_node(tagname, attributes, node=children[-1])
return result
return False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_last_child'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tagname'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '20', '41']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cur_node'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'getchildren'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'if_statement', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '22', 'type': 'block', 'children': ['23', '39']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_is_node'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tagname'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '37', 'type': 'unary_operator', 'children': ['38'], 'value': '-'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'False', 'children': []}
|
Check if last child of cur_node is tagname with attributes
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.