code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def resolve_targetfile(self, args, require_sim_name=False):
ttype = args.get('ttype')
if is_null(ttype):
sys.stderr.write('Target type must be specified')
return (None, None)
sim = args.get('sim')
if is_null(sim):
if require_sim_name:
sys.stderr.write('Simulation scenario must be specified')
return (None, None)
else:
sim = None
name_keys = dict(target_type=ttype,
targetlist='target_list.yaml',
sim_name=sim,
fullpath=True)
if sim is None:
targetfile = self.targetfile(**name_keys)
else:
targetfile = self.sim_targetfile(**name_keys)
targets_override = args.get('targetfile')
if is_not_null(targets_override):
targetfile = targets_override
return (targetfile, sim)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve_targetfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'require_sim_name'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '19', '38', '47', '75', '93', '120', '129', '139']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ttype'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'ttype'"}; {'id': '19', 'type': 'if_statement', 'children': ['20', '24']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'is_null'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ttype'}; {'id': '24', 'type': 'block', 'children': ['25', '34']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'Target type must be specified'"}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'tuple', 'children': ['36', '37']}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'sim'"}; {'id': '47', 'type': 'if_statement', 'children': ['48', '52']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'is_null'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'if_statement', 'children': ['54', '55', '69']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'require_sim_name'}; {'id': '55', 'type': 'block', 'children': ['56', '65']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '63']}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'Simulation scenario must be specified'"}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'tuple', 'children': ['67', '68']}; {'id': '67', 'type': 'None', 'children': []}; {'id': '68', 'type': 'None', 'children': []}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '74', 'type': 'None', 'children': []}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'name_keys'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '84', '87', '90']}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'target_type'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'ttype'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'targetlist'}; {'id': '86', 'type': 'string', 'children': [], 'value': "'target_list.yaml'"}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sim_name'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'fullpath'}; {'id': '92', 'type': 'True', 'children': []}; {'id': '93', 'type': 'if_statement', 'children': ['94', '97', '108']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'is'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'sim'}; {'id': '96', 'type': 'None', 'children': []}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'targetfile'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'targetfile'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'dictionary_splat', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'name_keys'}; {'id': '108', 'type': 'else_clause', 'children': ['109']}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'targetfile'}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'sim_targetfile'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'dictionary_splat', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'name_keys'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'targets_override'}; {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'string', 'children': [], 'value': "'targetfile'"}; {'id': '129', 'type': 'if_statement', 'children': ['130', '134']}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'is_not_null'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'targets_override'}; {'id': '134', 'type': 'block', 'children': ['135']}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'targetfile'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'targets_override'}; {'id': '139', 'type': 'return_statement', 'children': ['140']}; {'id': '140', 'type': 'tuple', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'targetfile'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'sim'}
|
Get the name of the targetfile based on the job arguments
|
def CheckIfCanStartClientFlow(self, username, flow_name):
del username
flow_cls = flow.GRRFlow.GetPlugin(flow_name)
if not flow_cls.category:
raise access_control.UnauthorizedAccess(
"Flow %s can't be started via the API." % flow_name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'CheckIfCanStartClientFlow'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '7', 'type': 'block', 'children': ['8', '10', '21']}; {'id': '8', 'type': 'delete_statement', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'flow_cls'}; {'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': 'flow'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'GRRFlow'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'GetPlugin'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'flow_name'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '26']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'flow_cls'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'raise_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'access_control'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'UnauthorizedAccess'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '%'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"Flow %s can\'t be started via the API."'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'flow_name'}
|
Checks whether a given user can start a given flow.
|
def compound_id(obj):
if isinstance(obj, (Category, Session)):
raise TypeError('Compound IDs are not supported for this entry type')
elif isinstance(obj, Event):
return unicode(obj.id)
elif isinstance(obj, Contribution):
return '{}.{}'.format(obj.event_id, obj.id)
elif isinstance(obj, SubContribution):
return '{}.{}.{}'.format(obj.contribution.event_id, obj.contribution_id, obj.id)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compound_id'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14', '20', '34', '53']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '11', 'type': 'tuple', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Category'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Session'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'Compound IDs are not supported for this entry type'"}; {'id': '20', 'type': 'elif_clause', 'children': ['21', '26']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Event'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '34', 'type': 'elif_clause', 'children': ['35', '40']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Contribution'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'{}.{}'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'event_id'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '53', 'type': 'elif_clause', 'children': ['54', '59']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'SubContribution'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'{}.{}.{}'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '71', '74']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'contribution'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'event_id'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'contribution_id'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'id'}
|
Generate a hierarchical compound ID, separated by dots.
|
def add_dup(self, pkt):
log.debug("Recording a dup of %s", pkt)
s = str(pkt)
if s in self.dups:
self.dups[s] += 1
else:
self.dups[s] = 1
tftpassert(self.dups[s] < MAX_DUPS, "Max duplicates reached")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_dup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pkt'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '22', '47']}; {'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': 'log'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"Recording a dup of %s"'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pkt'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'pkt'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '28', '37']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'in'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dups'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'augmented_assignment', 'children': ['31', '36'], 'value': '+='}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dups'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'else_clause', 'children': ['38']}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '46']}; {'id': '41', 'type': 'subscript', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dups'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'tftpassert'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '58']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '57'], 'value': '<'}; {'id': '52', 'type': 'subscript', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'dups'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'MAX_DUPS'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"Max duplicates reached"'}
|
This method adds a dup for a packet to the metrics.
|
def __normalize_progress(self):
progress = self['funding_progress']
if progress % 10 != 0:
progress = round(float(progress) / 10)
progress = int(progress) * 10
self['funding_progress'] = progress
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__normalize_progress'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'progress'}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'funding_progress'"}; {'id': '12', 'type': 'if_statement', 'children': ['13', '18']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': '!='}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '16'], 'value': '%'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'progress'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'block', 'children': ['19', '31', '40']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'progress'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '30'], 'value': '/'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'progress'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'progress'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '39'], 'value': '*'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'progress'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'funding_progress'"}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'progress'}
|
Adjust the funding progress filter to be a factor of 10
|
def check_unique(self):
errors = []
service_id = getattr(self, 'id', None)
fields = [('location', views.service_location),
('name', views.service_name)]
for field, view in fields:
value = getattr(self, field, None)
if not value:
continue
result = yield view.values(key=value)
matched = {x['id'] for x in result if x['id'] != service_id}
if matched:
errors.append("Service with {} '{}' already exists"
.format(field, value))
if errors:
raise exceptions.ValidationError(errors)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_unique'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '19', '33', '97']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'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': 'service_id'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '18']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '22', 'type': 'list', 'children': ['23', '28'], 'value': "[('location', views.service_location),\n ('name', views.service_name)]"}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'location'"}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'views'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'service_location'}; {'id': '28', 'type': 'tuple', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'views'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'service_name'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '37', '38']}; {'id': '34', 'type': 'pattern_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '38', 'type': 'block', 'children': ['39', '48', '53', '65', '81']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '47', 'type': 'None', 'children': []}; {'id': '48', 'type': 'if_statement', 'children': ['49', '51']}; {'id': '49', 'type': 'not_operator', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'continue_statement', 'children': []}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '56', 'type': 'yield', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'matched'}; {'id': '68', 'type': 'set_comprehension', 'children': ['69', '72', '75']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '72', 'type': 'for_in_clause', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '75', 'type': 'if_clause', 'children': ['76']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '80'], 'value': '!='}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'service_id'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'matched'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'string', 'children': [], 'value': '"Service with {} \'{}\' already exists"'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '97', 'type': 'if_statement', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'raise_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'ValidationError'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'errors'}
|
Check the service's name and location are unique
|
def _convert_type(self, data_type):
if (data_type == 1) or (data_type == 41):
dt_string = 'b'
elif data_type == 2:
dt_string = 'h'
elif data_type == 4:
dt_string = 'i'
elif (data_type == 8) or (data_type == 33):
dt_string = 'q'
elif data_type == 11:
dt_string = 'B'
elif data_type == 12:
dt_string = 'H'
elif data_type == 14:
dt_string = 'I'
elif (data_type == 21) or (data_type == 44):
dt_string = 'f'
elif (data_type == 22) or (data_type == 45) or (data_type == 31):
dt_string = 'd'
elif (data_type == 32):
dt_string = 'd'
elif (data_type == 51) or (data_type == 52):
dt_string = 's'
return dt_string
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '6', 'type': 'block', 'children': ['7', '142']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '17', '22', '31', '40', '55', '64', '73', '82', '97', '117', '127']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '13'], 'value': 'or'}; {'id': '9', 'type': '()', 'children': ['10']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': '=='}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': '=='}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '41'}; {'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': 'dt_string'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'b'"}; {'id': '22', 'type': 'elif_clause', 'children': ['23', '26']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': '=='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '2'}; {'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': 'dt_string'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'h'"}; {'id': '31', 'type': 'elif_clause', 'children': ['32', '35']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': '=='}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'i'"}; {'id': '40', 'type': 'elif_clause', 'children': ['41', '50']}; {'id': '41', 'type': 'boolean_operator', 'children': ['42', '46'], 'value': 'or'}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': '=='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': '=='}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '33'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'q'"}; {'id': '55', 'type': 'elif_clause', 'children': ['56', '59']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': '=='}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'B'"}; {'id': '64', 'type': 'elif_clause', 'children': ['65', '68']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': '=='}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '12'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'H'"}; {'id': '73', 'type': 'elif_clause', 'children': ['74', '77']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': '=='}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '14'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '81', 'type': 'string', 'children': [], 'value': "'I'"}; {'id': '82', 'type': 'elif_clause', 'children': ['83', '92']}; {'id': '83', 'type': 'boolean_operator', 'children': ['84', '88'], 'value': 'or'}; {'id': '84', 'type': '()', 'children': ['85']}; {'id': '85', 'type': 'comparison_operator', 'children': ['86', '87'], 'value': '=='}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '21'}; {'id': '88', 'type': '()', 'children': ['89']}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '91'], 'value': '=='}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '44'}; {'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': 'dt_string'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'f'"}; {'id': '97', 'type': 'elif_clause', 'children': ['98', '112']}; {'id': '98', 'type': 'boolean_operator', 'children': ['99', '108'], 'value': 'or'}; {'id': '99', 'type': 'boolean_operator', 'children': ['100', '104'], 'value': 'or'}; {'id': '100', 'type': '()', 'children': ['101']}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '103'], 'value': '=='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '22'}; {'id': '104', 'type': '()', 'children': ['105']}; {'id': '105', 'type': 'comparison_operator', 'children': ['106', '107'], 'value': '=='}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '107', 'type': 'integer', 'children': [], 'value': '45'}; {'id': '108', 'type': '()', 'children': ['109']}; {'id': '109', 'type': 'comparison_operator', 'children': ['110', '111'], 'value': '=='}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '111', 'type': 'integer', 'children': [], 'value': '31'}; {'id': '112', 'type': 'block', 'children': ['113']}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '116', 'type': 'string', 'children': [], 'value': "'d'"}; {'id': '117', 'type': 'elif_clause', 'children': ['118', '122']}; {'id': '118', 'type': '()', 'children': ['119']}; {'id': '119', 'type': 'comparison_operator', 'children': ['120', '121'], 'value': '=='}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '121', 'type': 'integer', 'children': [], 'value': '32'}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '126', 'type': 'string', 'children': [], 'value': "'d'"}; {'id': '127', 'type': 'elif_clause', 'children': ['128', '137']}; {'id': '128', 'type': 'boolean_operator', 'children': ['129', '133'], 'value': 'or'}; {'id': '129', 'type': '()', 'children': ['130']}; {'id': '130', 'type': 'comparison_operator', 'children': ['131', '132'], 'value': '=='}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '132', 'type': 'integer', 'children': [], 'value': '51'}; {'id': '133', 'type': '()', 'children': ['134']}; {'id': '134', 'type': 'comparison_operator', 'children': ['135', '136'], 'value': '=='}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '136', 'type': 'integer', 'children': [], 'value': '52'}; {'id': '137', 'type': 'block', 'children': ['138']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'dt_string'}; {'id': '141', 'type': 'string', 'children': [], 'value': "'s'"}; {'id': '142', 'type': 'return_statement', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'dt_string'}
|
CDF data types to python struct data types
|
def _create_body(self, name, description=None, volume=None, force=False):
body = {"snapshot": {
"display_name": name,
"display_description": description,
"volume_id": volume.id,
"force": str(force).lower(),
}}
return body
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_body'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '14', 'type': 'False', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16', '44']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '19', 'type': 'dictionary', 'children': ['20']}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"snapshot"'}; {'id': '22', 'type': 'dictionary', 'children': ['23', '26', '29', '34']}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"display_name"'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"display_description"'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"volume_id"'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"force"'}; {'id': '36', 'type': 'call', 'children': ['37', '43']}; {'id': '37', 'type': 'attribute', 'children': ['38', '42']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'body'}
|
Used to create the dict required to create a new snapshot
|
def init_app(application):
for code in werkzeug.exceptions.default_exceptions:
application.register_error_handler(code, handle_http_exception)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init_app'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'application'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '13']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'werkzeug'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'default_exceptions'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'application'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'register_error_handler'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'handle_http_exception'}
|
Associates the error handler
|
def param(name, help=""):
def decorator(func):
params = getattr(func, "params", [])
_param = Param(name, help)
params.insert(0, _param)
func.params = params
return func
return decorator
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'param'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '7', 'type': 'string', 'children': [], 'value': '""'}; {'id': '8', 'type': 'block', 'children': ['9', '47']}; {'id': '9', 'type': 'function_definition', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'function_name', 'children': [], 'value': 'decorator'}; {'id': '11', 'type': 'parameters', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '13', 'type': 'block', 'children': ['14', '23', '31', '39', '45']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"params"'}; {'id': '22', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_param'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Param'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_param'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'decorator'}
|
Decorator that add a parameter to the wrapped command or function.
|
def load_cash_balances_with_children(self, root_account_fullname: str):
assert isinstance(root_account_fullname, str)
svc = AccountsAggregate(self.book)
root_account = svc.get_by_fullname(root_account_fullname)
if not root_account:
raise ValueError("Account not found", root_account_fullname)
accounts = self.__get_all_child_accounts_as_array(root_account)
model = {}
for account in accounts:
if account.commodity.namespace != "CURRENCY" or account.placeholder:
continue
currency_symbol = account.commodity.mnemonic
if not currency_symbol in model:
currency_record = {
"name": currency_symbol,
"total": 0,
"rows": []
}
model[currency_symbol] = currency_record
else:
currency_record = model[currency_symbol]
balance = account.get_balance()
row = {
"name": account.name,
"fullname": account.fullname,
"currency": currency_symbol,
"balance": balance
}
currency_record["rows"].append(row)
total = Decimal(currency_record["total"])
total += balance
currency_record["total"] = total
return model
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_cash_balances_with_children'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'root_account_fullname'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'block', 'children': ['10', '16', '25', '34', '44', '53', '57', '172']}; {'id': '10', 'type': 'assert_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'root_account_fullname'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'svc'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'AccountsAggregate'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'book'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'root_account'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'svc'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get_by_fullname'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'root_account_fullname'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '37']}; {'id': '35', 'type': 'not_operator', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'root_account'}; {'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', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"Account not found"'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'root_account_fullname'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'accounts'}; {'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': '__get_all_child_accounts_as_array'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'root_account'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '56', 'type': 'dictionary', 'children': []}; {'id': '57', 'type': 'for_statement', 'children': ['58', '59', '60']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'accounts'}; {'id': '60', 'type': 'block', 'children': ['61', '75', '83', '116', '124', '144', '153', '162', '166']}; {'id': '61', 'type': 'if_statement', 'children': ['62', '73']}; {'id': '62', 'type': 'boolean_operator', 'children': ['63', '70'], 'value': 'or'}; {'id': '63', 'type': 'comparison_operator', 'children': ['64', '69'], 'value': '!='}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'commodity'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"CURRENCY"'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'placeholder'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'continue_statement', 'children': []}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'currency_symbol'}; {'id': '78', 'type': 'attribute', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'commodity'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'mnemonic'}; {'id': '83', 'type': 'if_statement', 'children': ['84', '88', '108']}; {'id': '84', 'type': 'not_operator', 'children': ['85']}; {'id': '85', 'type': 'comparison_operator', 'children': ['86', '87'], 'value': 'in'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'currency_symbol'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '88', 'type': 'block', 'children': ['89', '102']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'currency_record'}; {'id': '92', 'type': 'dictionary', 'children': ['93', '96', '99']}; {'id': '93', 'type': 'pair', 'children': ['94', '95']}; {'id': '94', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'currency_symbol'}; {'id': '96', 'type': 'pair', 'children': ['97', '98']}; {'id': '97', 'type': 'string', 'children': [], 'value': '"total"'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '99', 'type': 'pair', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': '"rows"'}; {'id': '101', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '107']}; {'id': '104', 'type': 'subscript', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'currency_symbol'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'currency_record'}; {'id': '108', 'type': 'else_clause', 'children': ['109']}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'currency_record'}; {'id': '113', 'type': 'subscript', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'currency_symbol'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'balance'}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'get_balance'}; {'id': '123', 'type': 'argument_list', 'children': []}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '127', 'type': 'dictionary', 'children': ['128', '133', '138', '141']}; {'id': '128', 'type': 'pair', 'children': ['129', '130']}; {'id': '129', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '133', 'type': 'pair', 'children': ['134', '135']}; {'id': '134', 'type': 'string', 'children': [], 'value': '"fullname"'}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'account'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'fullname'}; {'id': '138', 'type': 'pair', 'children': ['139', '140']}; {'id': '139', 'type': 'string', 'children': [], 'value': '"currency"'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'currency_symbol'}; {'id': '141', 'type': 'pair', 'children': ['142', '143']}; {'id': '142', 'type': 'string', 'children': [], 'value': '"balance"'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'balance'}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}; {'id': '145', 'type': 'call', 'children': ['146', '151']}; {'id': '146', 'type': 'attribute', 'children': ['147', '150']}; {'id': '147', 'type': 'subscript', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'currency_record'}; {'id': '149', 'type': 'string', 'children': [], 'value': '"rows"'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '151', 'type': 'argument_list', 'children': ['152']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '156', 'type': 'call', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'id': '158', 'type': 'argument_list', 'children': ['159']}; {'id': '159', 'type': 'subscript', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'currency_record'}; {'id': '161', 'type': 'string', 'children': [], 'value': '"total"'}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}; {'id': '163', 'type': 'augmented_assignment', 'children': ['164', '165'], 'value': '+='}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'balance'}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}; {'id': '167', 'type': 'assignment', 'children': ['168', '171']}; {'id': '168', 'type': 'subscript', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'currency_record'}; {'id': '170', 'type': 'string', 'children': [], 'value': '"total"'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '172', 'type': 'return_statement', 'children': ['173']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'model'}
|
loads data for cash balances
|
def _dissect_msg(self, match):
recvfrom = match.group(1)
frame = bytes.fromhex(match.group(2))
if recvfrom == 'E':
_LOGGER.warning("Received erroneous message, ignoring: %s", frame)
return (None, None, None, None, None)
msgtype = self._get_msgtype(frame[0])
if msgtype in (READ_ACK, WRITE_ACK, READ_DATA, WRITE_DATA):
data_id = frame[1:2]
data_msb = frame[2:3]
data_lsb = frame[3:4]
return (recvfrom, msgtype, data_id, data_msb, data_lsb)
return (None, None, None, None, None)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_dissect_msg'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '30', '50', '61', '104']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'recvfrom'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fromhex'}; {'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': 'match'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '34']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': '=='}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'recvfrom'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'E'"}; {'id': '34', 'type': 'block', 'children': ['35', '43']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_LOGGER'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': '"Received erroneous message, ignoring: %s"'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'tuple', 'children': ['45', '46', '47', '48', '49']}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'None', 'children': []}; {'id': '47', 'type': 'None', 'children': []}; {'id': '48', 'type': 'None', 'children': []}; {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'msgtype'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_get_msgtype'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '69']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': 'in'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'msgtype'}; {'id': '64', 'type': 'tuple', 'children': ['65', '66', '67', '68']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'READ_ACK'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'WRITE_ACK'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'READ_DATA'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'WRITE_DATA'}; {'id': '69', 'type': 'block', 'children': ['70', '79', '88', '97']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'data_id'}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '75', 'type': 'slice', 'children': ['76', '77', '78']}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'colon', 'children': []}; {'id': '78', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'data_msb'}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '84', 'type': 'slice', 'children': ['85', '86', '87']}; {'id': '85', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '86', 'type': 'colon', 'children': []}; {'id': '87', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'data_lsb'}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '93', 'type': 'slice', 'children': ['94', '95', '96']}; {'id': '94', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '95', 'type': 'colon', 'children': []}; {'id': '96', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'tuple', 'children': ['99', '100', '101', '102', '103']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'recvfrom'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'msgtype'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'data_id'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'data_msb'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'data_lsb'}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'tuple', 'children': ['106', '107', '108', '109', '110']}; {'id': '106', 'type': 'None', 'children': []}; {'id': '107', 'type': 'None', 'children': []}; {'id': '108', 'type': 'None', 'children': []}; {'id': '109', 'type': 'None', 'children': []}; {'id': '110', 'type': 'None', 'children': []}
|
Split messages into bytes and return a tuple of bytes.
|
def scheduler(rq, ctx, verbose, burst, queue, interval, pid):
"Periodically checks for scheduled jobs."
scheduler = rq.get_scheduler(interval=interval, queue=queue)
if pid:
with open(os.path.expanduser(pid), 'w') as fp:
fp.write(str(os.getpid()))
if verbose:
level = 'DEBUG'
else:
level = 'INFO'
setup_loghandlers(level)
scheduler.run(burst=burst)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scheduler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'rq'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'burst'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '11', 'type': 'block', 'children': ['12', '14', '28', '64', '77', '82']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"Periodically checks for scheduled jobs."'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'scheduler'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'rq'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get_scheduler'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '25']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'with_statement', 'children': ['32', '49']}; {'id': '32', 'type': 'with_clause', 'children': ['33']}; {'id': '33', 'type': 'with_item', 'children': ['34']}; {'id': '34', 'type': 'as_pattern', 'children': ['35', '47']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '46']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '47', 'type': 'as_pattern_target', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'str'}; {'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': 'os'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'getpid'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'if_statement', 'children': ['65', '66', '71']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'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': 'level'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'DEBUG'"}; {'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': 'level'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'INFO'"}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'setup_loghandlers'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'scheduler'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'keyword_argument', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'burst'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'burst'}
|
Periodically checks for scheduled jobs.
|
def _auth(self, username, password) :
self.user_credentials = self.call('auth', {'username': username, 'password': password})
if 'error' in self.user_credentials:
raise T411Exception('Error while fetching authentication token: %s'\
% self.user_credentials['error'])
user_data = dumps({'uid': '%s' % self.user_credentials['uid'], 'token': '%s' % self.user_credentials['token']})
with open(USER_CREDENTIALS_FILE, 'w') as user_cred_file:
user_cred_file.write(user_data)
return True
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_auth'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '7', 'type': 'block', 'children': ['8', '26', '45', '70', '89']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'user_credentials'}; {'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': 'call'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'auth'"}; {'id': '19', 'type': 'dictionary', 'children': ['20', '23']}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'username'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'password'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '32']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'in'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'user_credentials'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'raise_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'T411Exception'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39', '40'], 'value': '%'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'Error while fetching authentication token: %s'"}; {'id': '39', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'user_credentials'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'user_data'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'dictionary', 'children': ['52', '61']}; {'id': '52', 'type': 'pair', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'uid'"}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '%'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'%s'"}; {'id': '56', 'type': 'subscript', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'user_credentials'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'uid'"}; {'id': '61', 'type': 'pair', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'token'"}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '%'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'%s'"}; {'id': '65', 'type': 'subscript', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'user_credentials'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'token'"}; {'id': '70', 'type': 'with_statement', 'children': ['71', '81']}; {'id': '71', 'type': 'with_clause', 'children': ['72']}; {'id': '72', 'type': 'with_item', 'children': ['73']}; {'id': '73', 'type': 'as_pattern', 'children': ['74', '79']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'USER_CREDENTIALS_FILE'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '79', 'type': 'as_pattern_target', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'user_cred_file'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'user_cred_file'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'user_data'}; {'id': '89', 'type': 'return_statement', 'children': ['90']}; {'id': '90', 'type': 'True', 'children': []}
|
Authentificate user and store token
|
def erank(self):
r = self.r
n = self.n
d = self.d
if d <= 1:
er = 0e0
else:
sz = _np.dot(n * r[0:d], r[1:])
if sz == 0:
er = 0e0
else:
b = r[0] * n[0] + n[d - 1] * r[d]
if d is 2:
er = sz * 1.0 / b
else:
a = _np.sum(n[1:d - 1])
er = (_np.sqrt(b * b + 4 * a * sz) - b) / (2 * a)
return er
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'erank'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '24', '143']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28', '33']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': '<='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'er'}; {'id': '32', 'type': 'float', 'children': [], 'value': '0e0'}; {'id': '33', 'type': 'else_clause', 'children': ['34']}; {'id': '34', 'type': 'block', 'children': ['35', '56']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sz'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_np'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'dot'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '51']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '*'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '47', 'type': 'slice', 'children': ['48', '49', '50']}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '49', 'type': 'colon', 'children': []}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '53', 'type': 'slice', 'children': ['54', '55']}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'colon', 'children': []}; {'id': '56', 'type': 'if_statement', 'children': ['57', '60', '65']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '59'], 'value': '=='}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'sz'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'er'}; {'id': '64', 'type': 'float', 'children': [], 'value': '0e0'}; {'id': '65', 'type': 'else_clause', 'children': ['66']}; {'id': '66', 'type': 'block', 'children': ['67', '87']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '78'], 'value': '+'}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '75'], 'value': '*'}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '84'], 'value': '*'}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '83'], 'value': '-'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '87', 'type': 'if_statement', 'children': ['88', '91', '100']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '90'], 'value': 'is'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'er'}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '99'], 'value': '/'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '98'], 'value': '*'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'sz'}; {'id': '98', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '100', 'type': 'else_clause', 'children': ['101']}; {'id': '101', 'type': 'block', 'children': ['102', '118']}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': '_np'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '112', 'type': 'slice', 'children': ['113', '114', '115']}; {'id': '113', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '114', 'type': 'colon', 'children': []}; {'id': '115', 'type': 'binary_operator', 'children': ['116', '117'], 'value': '-'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '117', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'assignment', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'er'}; {'id': '121', 'type': 'binary_operator', 'children': ['122', '139'], 'value': '/'}; {'id': '122', 'type': '()', 'children': ['123']}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '138'], 'value': '-'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': '_np'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'binary_operator', 'children': ['130', '133'], 'value': '+'}; {'id': '130', 'type': 'binary_operator', 'children': ['131', '132'], 'value': '*'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '133', 'type': 'binary_operator', 'children': ['134', '137'], 'value': '*'}; {'id': '134', 'type': 'binary_operator', 'children': ['135', '136'], 'value': '*'}; {'id': '135', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'sz'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '139', 'type': '()', 'children': ['140']}; {'id': '140', 'type': 'binary_operator', 'children': ['141', '142'], 'value': '*'}; {'id': '141', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '143', 'type': 'return_statement', 'children': ['144']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'er'}
|
Effective rank of the TT-vector
|
def rotateCD(self,orient):
_delta = self.get_orient() - orient
if _delta == 0.:
return
_rot = fileutil.buildRotMatrix(_delta)
_cd = N.array([[self.cd11,self.cd12],[self.cd21,self.cd22]],dtype=N.float64)
_cdrot = N.dot(_cd,_rot)
self.cd11 = _cdrot[0][0]
self.cd12 = _cdrot[0][1]
self.cd21 = _cdrot[1][0]
self.cd22 = _cdrot[1][1]
self.orient = orient
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rotateCD'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'orient'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '23', '32', '60', '70', '80', '90', '100', '110']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_delta'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '16'], 'value': '-'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_orient'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'orient'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': '=='}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_delta'}; {'id': '20', 'type': 'float', 'children': [], 'value': '0.'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_rot'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'fileutil'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'buildRotMatrix'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_delta'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_cd'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '55']}; {'id': '40', 'type': 'list', 'children': ['41', '48'], 'value': '[[self.cd11,self.cd12],[self.cd21,self.cd22]]'}; {'id': '41', 'type': 'list', 'children': ['42', '45'], 'value': '[self.cd11,self.cd12]'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cd11'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'cd12'}; {'id': '48', 'type': 'list', 'children': ['49', '52'], 'value': '[self.cd21,self.cd22]'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cd21'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cd22'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'float64'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_cdrot'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'dot'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_cd'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_rot'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'cd11'}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': '_cdrot'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'cd12'}; {'id': '85', 'type': 'subscript', 'children': ['86', '89']}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': '_cdrot'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'cd21'}; {'id': '95', 'type': 'subscript', 'children': ['96', '99']}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': '_cdrot'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '99', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'cd22'}; {'id': '105', 'type': 'subscript', 'children': ['106', '109']}; {'id': '106', 'type': 'subscript', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': '_cdrot'}; {'id': '108', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '109', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'orient'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'orient'}
|
Rotates WCS CD matrix to new orientation given by 'orient'
|
def as_text(self, max_rows=0, sep=" | "):
if not max_rows or max_rows > self.num_rows:
max_rows = self.num_rows
omitted = max(0, self.num_rows - max_rows)
labels = self._columns.keys()
fmts = self._get_column_formatters(max_rows, False)
rows = [[fmt(label, label=True) for fmt, label in zip(fmts, labels)]]
for row in itertools.islice(self.rows, max_rows):
rows.append([f(v, label=False) for v, f in zip(row, fmts)])
lines = [sep.join(row) for row in rows]
if omitted:
lines.append('... ({} rows omitted)'.format(omitted))
return '\n'.join([line.rstrip() for line in lines])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_text'}; {'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': 'max_rows'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '10', 'type': 'string', 'children': [], 'value': '" | "'}; {'id': '11', 'type': 'block', 'children': ['12', '28', '40', '50', '60', '81', '116', '129', '144']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '21']}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '16'], 'value': 'or'}; {'id': '14', 'type': 'not_operator', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'max_rows'}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '>'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'max_rows'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'num_rows'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'max_rows'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'num_rows'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'omitted'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '39'], 'value': '-'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'num_rows'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'max_rows'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_columns'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'fmts'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_get_column_formatters'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'max_rows'}; {'id': '59', 'type': 'False', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '63', 'type': 'list', 'children': ['64'], 'value': '[[fmt(label, label=True) for fmt, label in zip(fmts, labels)]]'}; {'id': '64', 'type': 'list_comprehension', 'children': ['65', '72']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '71', 'type': 'True', 'children': []}; {'id': '72', 'type': 'for_in_clause', 'children': ['73', '76']}; {'id': '73', 'type': 'pattern_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'fmts'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '81', 'type': 'for_statement', 'children': ['82', '83', '92']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'itertools'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'islice'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'max_rows'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'list_comprehension', 'children': ['100', '107']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '106', 'type': 'False', 'children': []}; {'id': '107', 'type': 'for_in_clause', 'children': ['108', '111']}; {'id': '108', 'type': 'pattern_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'fmts'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '119', 'type': 'list_comprehension', 'children': ['120', '126']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '126', 'type': 'for_in_clause', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '129', 'type': 'if_statement', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'omitted'}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'string', 'children': [], 'value': "'... ({} rows omitted)'"}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'omitted'}; {'id': '144', 'type': 'return_statement', 'children': ['145']}; {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'list_comprehension', 'children': ['151', '156']}; {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '155', 'type': 'argument_list', 'children': []}; {'id': '156', 'type': 'for_in_clause', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'lines'}
|
Format table as text.
|
def remove_index(self, index):
'remove one or more indices'
index_rm, single = convert_key_to_index(force_list(self.indices.keys()), index)
if single:
index_rm = [index_rm]
index_new = [i for i in range(len(self.indices)) if i not in index_rm]
if not index_new:
self.clear(True)
return
names = mget_list(force_list(self.indices.keys()), index_new)
items = [mget_list(i, index_new) for i in self.items()]
self.clear(True)
_MI_init(self, items, names)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '28', '36', '56', '68', '85', '101', '108']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': "'remove one or more indices'"}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'index_rm'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'single'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'convert_key_to_index'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '27']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'force_list'}; {'id': '19', 'type': 'argument_list', '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': 'indices'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'single'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'index_rm'}; {'id': '34', 'type': 'list', 'children': ['35'], 'value': '[index_rm]'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'index_rm'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'index_new'}; {'id': '39', 'type': 'list_comprehension', 'children': ['40', '41', '52']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '52', 'type': 'if_clause', 'children': ['53']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': 'not in'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'index_rm'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '59']}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'index_new'}; {'id': '59', 'type': 'block', 'children': ['60', '67']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'True', 'children': []}; {'id': '67', 'type': 'return_statement', 'children': []}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'mget_list'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '84']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'force_list'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '83']}; {'id': '78', 'type': 'attribute', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'index_new'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '88', 'type': 'list_comprehension', 'children': ['89', '94']}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'mget_list'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'index_new'}; {'id': '94', 'type': 'for_in_clause', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'i'}; {'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': 'items'}; {'id': '100', 'type': 'argument_list', 'children': []}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'True', 'children': []}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': '_MI_init'}; {'id': '111', 'type': 'argument_list', 'children': ['112', '113', '114']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'names'}
|
remove one or more indices
|
def fincre(oldname):
x=re.search('_(?P<version>[0-9][0-9][0-9])_syn',oldname)
version=x.group('version')
newversion="%03d"%(int(version)+1)
ans=oldname.replace(version,newversion)
return ans
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fincre'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'oldname'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '25', '37', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'_(?P<version>[0-9][0-9][0-9])_syn'"}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'oldname'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'version'"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'newversion'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '%'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"%03d"'}; {'id': '30', 'type': '()', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '36'], 'value': '+'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ans'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'oldname'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'newversion'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ans'}
|
Increment the synphot version number from a filename
|
def _parse_entity(self):
reset = self._head
try:
self._push(contexts.HTML_ENTITY)
self._really_parse_entity()
except BadRoute:
self._head = reset
self._emit_text(self._read())
else:
self._emit_all(self._pop())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_entity'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_head'}; {'id': '12', 'type': 'try_statement', 'children': ['13', '29', '49']}; {'id': '13', 'type': 'block', 'children': ['14', '23']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_push'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'contexts'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'HTML_ENTITY'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_really_parse_entity'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'except_clause', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'BadRoute'}; {'id': '31', 'type': 'block', 'children': ['32', '38']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_head'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'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': '_emit_text'}; {'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': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_read'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_emit_all'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_pop'}; {'id': '61', 'type': 'argument_list', 'children': []}
|
Parse an HTML entity at the head of the wikicode string.
|
def check_length_of_initial_values(self, init_values):
num_nests = self.rows_to_nests.shape[1]
num_index_coefs = self.design.shape[1]
assumed_param_dimensions = num_index_coefs + num_nests
if init_values.shape[0] != assumed_param_dimensions:
msg = "The initial values are of the wrong dimension"
msg_1 = "It should be of dimension {}"
msg_2 = "But instead it has dimension {}"
raise ValueError(msg +
msg_1.format(assumed_param_dimensions) +
msg_2.format(init_values.shape[0]))
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_length_of_initial_values'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'init_values'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '27', '33', '77']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'num_nests'}; {'id': '10', 'type': 'subscript', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'rows_to_nests'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'num_index_coefs'}; {'id': '20', 'type': 'subscript', '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': 'design'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'assumed_param_dimensions'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '32'], 'value': '+'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'num_index_coefs'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'num_nests'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '41']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '40'], 'value': '!='}; {'id': '35', 'type': 'subscript', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'init_values'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'assumed_param_dimensions'}; {'id': '41', 'type': 'block', 'children': ['42', '46', '50', '54']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"The initial values are of the wrong dimension"'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'msg_1'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"It should be of dimension {}"'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'msg_2'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"But instead it has dimension {}"'}; {'id': '54', 'type': 'raise_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '67'], 'value': '+'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '+'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'msg_1'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'assumed_param_dimensions'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'msg_2'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'subscript', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'init_values'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'None', 'children': []}
|
Ensures that the initial values are of the correct length.
|
def detect_fts(conn, table):
"Detect if table has a corresponding FTS virtual table and return it"
rows = conn.execute(detect_fts_sql(table)).fetchall()
if len(rows) == 0:
return None
else:
return rows[0][0]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'detect_fts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Detect if table has a corresponding FTS virtual table and return it"'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '12', 'type': 'call', 'children': ['13', '24']}; {'id': '13', 'type': 'attribute', 'children': ['14', '23']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'detect_fts_sql'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'fetchall'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '32', '35']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '31'], 'value': '=='}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}
|
Detect if table has a corresponding FTS virtual table and return it
|
def position_p(self):
self._position_p, value = self.get_attr_int(self._position_p, 'hold_pid/Kp')
return value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'position_p'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '22']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '13']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_position_p'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get_attr_int'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_position_p'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'hold_pid/Kp'"}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'value'}
|
The proportional constant for the position PID.
|
def squarelim():
fig = gcf()
xmin, xmax = fig.xlim
ymin, ymax = fig.ylim
zmin, zmax = fig.zlim
width = max([abs(xmax - xmin), abs(ymax - ymin), abs(zmax - zmin)])
xc = (xmin + xmax) / 2
yc = (ymin + ymax) / 2
zc = (zmin + zmax) / 2
xlim(xc - width / 2, xc + width / 2)
ylim(yc - width / 2, yc + width / 2)
zlim(zc - width / 2, zc + width / 2)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'squarelim'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '19', '27', '35', '60', '69', '78', '87', '101', '115']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'gcf'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'xmin'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'xmax'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'xlim'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ymin'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ymax'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ylim'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'pattern_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'zmin'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'zmax'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'zlim'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'list', 'children': ['42', '48', '54'], 'value': '[abs(xmax - xmin), abs(ymax - ymin), abs(zmax - zmin)]'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '-'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'xmax'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'xmin'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '-'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ymax'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ymin'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '-'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'zmax'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'zmin'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'xc'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '68'], 'value': '/'}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '+'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'xmin'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'xmax'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'yc'}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '77'], 'value': '/'}; {'id': '73', 'type': '()', 'children': ['74']}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '76'], 'value': '+'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'ymin'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ymax'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'zc'}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '86'], 'value': '/'}; {'id': '82', 'type': '()', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '+'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'zmin'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'zmax'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'xlim'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '96']}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '93'], 'value': '-'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'xc'}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '95'], 'value': '/'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '95', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '98'], 'value': '+'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'xc'}; {'id': '98', 'type': 'binary_operator', 'children': ['99', '100'], 'value': '/'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '100', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'ylim'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '110']}; {'id': '105', 'type': 'binary_operator', 'children': ['106', '107'], 'value': '-'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'yc'}; {'id': '107', 'type': 'binary_operator', 'children': ['108', '109'], 'value': '/'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '109', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '110', 'type': 'binary_operator', 'children': ['111', '112'], 'value': '+'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'yc'}; {'id': '112', 'type': 'binary_operator', 'children': ['113', '114'], 'value': '/'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '114', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'zlim'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '124']}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '121'], 'value': '-'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'zc'}; {'id': '121', 'type': 'binary_operator', 'children': ['122', '123'], 'value': '/'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '123', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '124', 'type': 'binary_operator', 'children': ['125', '126'], 'value': '+'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'zc'}; {'id': '126', 'type': 'binary_operator', 'children': ['127', '128'], 'value': '/'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '128', 'type': 'integer', 'children': [], 'value': '2'}
|
Set all axes with equal aspect ratio, such that the space is 'square'.
|
def node_detail(node_name):
token = session.get('token')
node = nago.core.get_node(token)
if not node.get('access') == 'master':
return jsonify(status='error', error="You need master access to view this page")
node = nago.core.get_node(node_name)
return render_template('node_detail.html', node=node)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'node_detail'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node_name'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '26', '47', '58']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'token'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'nago'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_node'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '36']}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '35'], 'value': '=='}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'access'"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'master'"}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'jsonify'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44']}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"You need master access to view this page"'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'nago'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'get_node'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'node_name'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'render_template'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'node_detail.html'"}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'node'}
|
View one specific node
|
def _api_model_patch_replace(conn, restApiId, modelName, path, value):
response = conn.update_model(restApiId=restApiId, modelName=modelName,
patchOperations=[{'op': 'replace', 'path': path, 'value': value}])
return response
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_api_model_patch_replace'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'restApiId'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'modelName'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '9', 'type': 'block', 'children': ['10', '37']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'update_model'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21', '24']}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'restApiId'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'restApiId'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'modelName'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'modelName'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'patchOperations'}; {'id': '26', 'type': 'list', 'children': ['27'], 'value': "[{'op': 'replace', 'path': path, 'value': value}]"}; {'id': '27', 'type': 'dictionary', 'children': ['28', '31', '34']}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'op'"}; {'id': '30', 'type': 'string', 'children': [], 'value': "'replace'"}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'path'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'response'}
|
the replace patch operation on a Model resource
|
def line_break(self):
for i in range(self.slide.insert_line_break):
if not self._in_tag(ns("text", "p")):
self.add_node(ns("text", "p"))
self.add_node(ns("text", "line-break"))
self.pop_node()
if self.cur_node.tag == ns("text", "p"):
return
if self.cur_node.getparent().tag != ns("text", "p"):
self.pop_node()
self.slide.insert_line_break = 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'line_break'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '95']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '16']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'slide'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'insert_line_break'}; {'id': '16', 'type': 'block', 'children': ['17', '41', '52', '58', '72']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '29']}; {'id': '18', 'type': 'not_operator', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_in_tag'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"p"'}; {'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': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'add_node'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"p"'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'add_node'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"line-break"'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'pop_node'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'if_statement', 'children': ['59', '70']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '65'], 'value': '=='}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'cur_node'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"p"'}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'return_statement', 'children': []}; {'id': '72', 'type': 'if_statement', 'children': ['73', '88']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '83'], 'value': '!='}; {'id': '74', 'type': 'attribute', 'children': ['75', '82']}; {'id': '75', 'type': 'call', 'children': ['76', '81']}; {'id': '76', 'type': 'attribute', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'cur_node'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'getparent'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'ns'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '87', 'type': 'string', 'children': [], 'value': '"p"'}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'pop_node'}; {'id': '94', 'type': 'argument_list', 'children': []}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '102']}; {'id': '97', 'type': 'attribute', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'slide'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'insert_line_break'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '0'}
|
insert as many line breaks as the insert_line_break variable says
|
def _get_root(self):
_DEFAULT_USER_DETAILS = {"level": 20, "password": "", "sshkeys": []}
root = {}
root_table = junos_views.junos_root_table(self.device)
root_table.get()
root_items = root_table.items()
for user_entry in root_items:
username = "root"
user_details = _DEFAULT_USER_DETAILS.copy()
user_details.update({d[0]: d[1] for d in user_entry[1] if d[1]})
user_details = {
key: py23_compat.text_type(user_details[key])
for key in user_details.keys()
}
user_details["level"] = int(user_details["level"])
user_details["sshkeys"] = [
user_details.pop(key)
for key in ["ssh_rsa", "ssh_dsa", "ssh_ecdsa"]
if user_details.get(key, "")
]
root[username] = user_details
return root
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_root'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '23', '34', '40', '48', '151']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_DEFAULT_USER_DETAILS'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '13', '16']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"level"'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '13', 'type': 'pair', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"password"'}; {'id': '15', 'type': 'string', 'children': [], 'value': '""'}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"sshkeys"'}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '22', 'type': 'dictionary', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'root_table'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'junos_views'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'junos_root_table'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'root_table'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'root_items'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'root_table'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '47', 'type': 'argument_list', 'children': []}; {'id': '48', 'type': 'for_statement', 'children': ['49', '50', '51']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'user_entry'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'root_items'}; {'id': '51', 'type': 'block', 'children': ['52', '56', '64', '87', '108', '119', '145']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"root"'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': '_DEFAULT_USER_DETAILS'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'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': 'user_details'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'dictionary_comprehension', 'children': ['71', '78', '83']}; {'id': '71', 'type': 'pair', 'children': ['72', '75']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '78', 'type': 'for_in_clause', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'user_entry'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'if_clause', 'children': ['84']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '90', 'type': 'dictionary_comprehension', 'children': ['91', '101']}; {'id': '91', 'type': 'pair', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'py23_compat'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'text_type'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '101', 'type': 'for_in_clause', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '113']}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '112', 'type': 'string', 'children': [], 'value': '"level"'}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '118', 'type': 'string', 'children': [], 'value': '"level"'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '124']}; {'id': '121', 'type': 'subscript', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '123', 'type': 'string', 'children': [], 'value': '"sshkeys"'}; {'id': '124', 'type': 'list_comprehension', 'children': ['125', '131', '137']}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '131', 'type': 'for_in_clause', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '133', 'type': 'list', 'children': ['134', '135', '136'], 'value': '["ssh_rsa", "ssh_dsa", "ssh_ecdsa"]'}; {'id': '134', 'type': 'string', 'children': [], 'value': '"ssh_rsa"'}; {'id': '135', 'type': 'string', 'children': [], 'value': '"ssh_dsa"'}; {'id': '136', 'type': 'string', 'children': [], 'value': '"ssh_ecdsa"'}; {'id': '137', 'type': 'if_clause', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '142', 'type': 'argument_list', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '144', 'type': 'string', 'children': [], 'value': '""'}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '150']}; {'id': '147', 'type': 'subscript', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'user_details'}; {'id': '151', 'type': 'return_statement', 'children': ['152']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'root'}
|
get root user password.
|
def Godeps(self):
dict = []
for package in sorted(self._packages.keys()):
dict.append({
"ImportPath": str(package),
"Rev": str(self._packages[package])
})
return dict
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Godeps'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '46']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '22']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_packages'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'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': 'dict'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'dictionary', 'children': ['30', '36']}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"ImportPath"'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '36', 'type': 'pair', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"Rev"'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'subscript', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_packages'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dict'}
|
Return the snapshot in Godeps.json form
|
def assets(self) -> List[Asset]:
return list(filter(is_element(Asset), self.content))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assets'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'generic_type', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '8', 'type': 'type_parameter', 'children': ['9']}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Asset'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '23']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'is_element'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Asset'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'content'}
|
Returns the assets in the transaction.
|
def _write(self, session, openFile, replaceParamFile):
openFile.write('GRIDSTREAMFILE\n')
openFile.write('STREAMCELLS %s\n' % self.streamCells)
for cell in self.gridStreamCells:
openFile.write('CELLIJ %s %s\n' % (cell.cellI, cell.cellJ))
openFile.write('NUMNODES %s\n' % cell.numNodes)
for node in cell.gridStreamNodes:
openFile.write('LINKNODE %s %s %.6f\n' % (
node.linkNumber,
node.nodeNumber,
node.nodePercentGrid))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'openFile'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'replaceParamFile'}; {'id': '8', 'type': 'block', 'children': ['9', '16', '27']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'openFile'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'GRIDSTREAMFILE\\n'"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'openFile'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '%'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'STREAMCELLS %s\\n'"}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'streamCells'}; {'id': '27', 'type': 'for_statement', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'gridStreamCells'}; {'id': '32', 'type': 'block', 'children': ['33', '48', '59']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'openFile'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '%'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'CELLIJ %s %s\\n'"}; {'id': '41', 'type': 'tuple', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cellI'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'cellJ'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'openFile'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '%'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'NUMNODES %s\\n'"}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'numNodes'}; {'id': '59', 'type': 'for_statement', 'children': ['60', '61', '64']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'gridStreamNodes'}; {'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': 'openFile'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '73'], 'value': '%'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'LINKNODE %s %s %.6f\\n'"}; {'id': '73', 'type': 'tuple', 'children': ['74', '77', '80']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'linkNumber'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'nodeNumber'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'nodePercentGrid'}
|
Grid Stream File Write to File Method
|
def com_google_fonts_check_family_panose_familytype(ttFonts):
failed = False
familytype = None
for ttfont in ttFonts:
if familytype is None:
familytype = ttfont['OS/2'].panose.bFamilyType
if familytype != ttfont['OS/2'].panose.bFamilyType:
failed = True
if failed:
yield FAIL, ("PANOSE family type is not"
" the same accross this family."
" In order to fix this,"
" please make sure that the panose.bFamilyType value"
" is the same in the OS/2 table of all of this family"
" font files.")
else:
yield PASS, "Fonts have consistent PANOSE family type."
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'com_google_fonts_check_family_panose_familytype'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ttFonts'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '48']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'failed'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'familytype'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '17']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ttfont'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ttFonts'}; {'id': '17', 'type': 'block', 'children': ['18', '33']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'is'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'familytype'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'familytype'}; {'id': '26', 'type': 'attribute', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ttfont'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'OS/2'"}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'panose'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'bFamilyType'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '43']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': '!='}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'familytype'}; {'id': '36', 'type': 'attribute', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ttfont'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'OS/2'"}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'panose'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'bFamilyType'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'failed'}; {'id': '47', 'type': 'True', 'children': []}; {'id': '48', 'type': 'if_statement', 'children': ['49', '50', '63']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'failed'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'yield', 'children': ['53']}; {'id': '53', 'type': 'expression_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'FAIL'}; {'id': '55', 'type': '()', 'children': ['56']}; {'id': '56', 'type': 'concatenated_string', 'children': ['57', '58', '59', '60', '61', '62']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"PANOSE family type is not"'}; {'id': '58', 'type': 'string', 'children': [], 'value': '" the same accross this family."'}; {'id': '59', 'type': 'string', 'children': [], 'value': '" In order to fix this,"'}; {'id': '60', 'type': 'string', 'children': [], 'value': '" please make sure that the panose.bFamilyType value"'}; {'id': '61', 'type': 'string', 'children': [], 'value': '" is the same in the OS/2 table of all of this family"'}; {'id': '62', 'type': 'string', 'children': [], 'value': '" font files."'}; {'id': '63', 'type': 'else_clause', 'children': ['64']}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'yield', 'children': ['67']}; {'id': '67', 'type': 'expression_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'PASS'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"Fonts have consistent PANOSE family type."'}
|
Fonts have consistent PANOSE family type?
|
def WriteProtoFile(self, printer):
self.Validate()
extended_descriptor.WriteMessagesFile(
self.__file_descriptor, self.__package, self.__client_info.version,
printer)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'WriteProtoFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'printer'}; {'id': '6', 'type': 'block', 'children': ['7', '13']}; {'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': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Validate'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'extended_descriptor'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'WriteMessagesFile'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '22', '25', '30']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '__file_descriptor'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '__package'}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '__client_info'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'printer'}
|
Write the messages file to out as proto.
|
def flush(self):
if self.__buffer.tell() > 0:
self.__logger._log(level=self.__log_level, msg=self.__buffer.getvalue().strip(),
record_filter=StdErrWrapper.__filter_record)
self.__buffer.truncate(0)
self.__buffer.seek(0)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flush'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '15'], 'value': '>'}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '__buffer'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'tell'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'block', 'children': ['17', '48', '57']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '__logger'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '30', '43']}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__log_level'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '32', 'type': 'call', 'children': ['33', '42']}; {'id': '33', 'type': 'attribute', 'children': ['34', '41']}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__buffer'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'getvalue'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'record_filter'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'StdErrWrapper'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '__filter_record'}; {'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': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '__buffer'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'truncate'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '__buffer'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}
|
Flush the buffer, if applicable.
|
def fmt_duration(duration):
try:
return fmt.human_duration(float(duration), 0, 2, True)
except (ValueError, TypeError):
return "N/A".rjust(len(fmt.human_duration(0, 0, 2, True)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fmt_duration'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'duration'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '21']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'human_duration'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '18', '19', '20']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'duration'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '20', 'type': 'True', 'children': []}; {'id': '21', 'type': 'except_clause', 'children': ['22', '25']}; {'id': '22', 'type': 'tuple', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'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': 'string', 'children': [], 'value': '"N/A"'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'rjust'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'human_duration'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41', '42', '43']}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '43', 'type': 'True', 'children': []}
|
Format a duration value in seconds to a readable form.
|
def value(self, units=None):
if units is None:
return self._value
if not units.upper() in CustomPressure.legal_units:
raise UnitsError("unrecognized pressure unit: '" + units + "'")
units = units.upper()
if units == self._units:
return self._value
if self._units == "IN":
mb_value = self._value * 33.86398
elif self._units == "MM":
mb_value = self._value * 1.3332239
else:
mb_value = self._value
if units in ("MB", "HPA"):
return mb_value
if units == "IN":
return mb_value / 33.86398
if units == "MM":
return mb_value / 1.3332239
raise UnitsError("unrecognized pressure unit: '" + units + "'")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '18', '39', '47', '58', '96', '105', '114', '123']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_value'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '29']}; {'id': '19', 'type': 'not_operator', 'children': ['20']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '26'], 'value': 'in'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'CustomPressure'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'legal_units'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'raise_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'UnitsError'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '38'], 'value': '+'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '+'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"unrecognized pressure unit: \'"'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"\'"'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'if_statement', 'children': ['48', '53']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': '=='}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_units'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_value'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '64', '73', '88']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '63'], 'value': '=='}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_units'}; {'id': '63', 'type': 'string', 'children': [], 'value': '"IN"'}; {'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': 'mb_value'}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '72'], 'value': '*'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_value'}; {'id': '72', 'type': 'float', 'children': [], 'value': '33.86398'}; {'id': '73', 'type': 'elif_clause', 'children': ['74', '79']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '78'], 'value': '=='}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': '_units'}; {'id': '78', 'type': 'string', 'children': [], 'value': '"MM"'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'mb_value'}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '87'], 'value': '*'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_value'}; {'id': '87', 'type': 'float', 'children': [], 'value': '1.3332239'}; {'id': '88', 'type': 'else_clause', 'children': ['89']}; {'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': 'mb_value'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '_value'}; {'id': '96', 'type': 'if_statement', 'children': ['97', '102']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': 'in'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '99', 'type': 'tuple', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': '"MB"'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"HPA"'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'mb_value'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '109']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': '=='}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '108', 'type': 'string', 'children': [], 'value': '"IN"'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'return_statement', 'children': ['111']}; {'id': '111', 'type': 'binary_operator', 'children': ['112', '113'], 'value': '/'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'mb_value'}; {'id': '113', 'type': 'float', 'children': [], 'value': '33.86398'}; {'id': '114', 'type': 'if_statement', 'children': ['115', '118']}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': '=='}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '117', 'type': 'string', 'children': [], 'value': '"MM"'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'return_statement', 'children': ['120']}; {'id': '120', 'type': 'binary_operator', 'children': ['121', '122'], 'value': '/'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'mb_value'}; {'id': '122', 'type': 'float', 'children': [], 'value': '1.3332239'}; {'id': '123', 'type': 'raise_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'UnitsError'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'binary_operator', 'children': ['128', '131'], 'value': '+'}; {'id': '128', 'type': 'binary_operator', 'children': ['129', '130'], 'value': '+'}; {'id': '129', 'type': 'string', 'children': [], 'value': '"unrecognized pressure unit: \'"'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '131', 'type': 'string', 'children': [], 'value': '"\'"'}
|
Return the pressure in the specified units.
|
def write_area_data(self, file):
file.write("%% area data" + "\n")
file.write("%\tno.\tprice_ref_bus" + "\n")
file.write("areas = [" + "\n")
file.write("\t1\t1;" + "\n")
file.write("];" + "\n")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_area_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '34', '43']}; {'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': 'file'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '15'], 'value': '+'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"%% area data"'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '+'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"%\\tno.\\tprice_ref_bus"'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '+'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"areas = ["'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '+'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"\\t1\\t1;"'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '+'}; {'id': '50', 'type': 'string', 'children': [], 'value': '"];"'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"\\n"'}
|
Writes area data to file.
|
def concatenate_attributes(attributes):
tpl = attributes[0]
attr = InstanceAttribute(tpl.name, tpl.shape,
tpl.dtype, tpl.dim, alias=None)
if all(a.size == 0 for a in attributes):
return attr
else:
attr.value = np.concatenate([a.value for a in attributes if a.size > 0], axis=0)
return attr
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'concatenate_attributes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '33']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tpl'}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'InstanceAttribute'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21', '24', '27', '30']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tpl'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tpl'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'tpl'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'tpl'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '32', 'type': 'None', 'children': []}; {'id': '33', 'type': 'if_statement', 'children': ['34', '45', '48']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '36', 'type': 'generator_expression', 'children': ['37', '42']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '41'], 'value': '=='}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '48', 'type': 'else_clause', 'children': ['49']}; {'id': '49', 'type': 'block', 'children': ['50', '76']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'concatenate'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '73']}; {'id': '60', 'type': 'list_comprehension', 'children': ['61', '64', '67']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '64', 'type': 'for_in_clause', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '67', 'type': 'if_clause', 'children': ['68']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '72'], 'value': '>'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'attr'}
|
Concatenate InstanceAttribute to return a bigger one.
|
def shell_join(delim, it):
'Joins an iterable of ShellQuoted with a delimiter between each two'
return ShellQuoted(delim.join(raw_shell(s) for s in it))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shell_join'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '6', 'type': 'block', 'children': ['7', '9']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': "'Joins an iterable of ShellQuoted with a delimiter between each two'"}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ShellQuoted'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'delim'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '17', 'type': 'generator_expression', 'children': ['18', '22']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'raw_shell'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'it'}
|
Joins an iterable of ShellQuoted with a delimiter between each two
|
def override(self, value):
if self._value is not value:
return _ScopedValueOverrideContext(self, value)
else:
return empty_context
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'override'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '20']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is not'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_value'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_ScopedValueOverrideContext'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '20', 'type': 'else_clause', 'children': ['21']}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'empty_context'}
|
Temporarily overrides the old value with the new one.
|
def copy(self):
data = QMimeData()
text = '\n'.join([cursor.selectedText() \
for cursor in self.cursors()])
data.setText(text)
data.setData(self.MIME_TYPE, text.encode('utf8'))
QApplication.clipboard().setMimeData(data)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '34', '41', '56']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'QMimeData'}; {'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': 'text'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'list_comprehension', 'children': ['21', '26', '27']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'selectedText'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '27', 'type': 'for_in_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cursors'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'setText'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'setData'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'MIME_TYPE'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'utf8'"}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '65']}; {'id': '58', 'type': 'attribute', 'children': ['59', '64']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'QApplication'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'clipboard'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'setMimeData'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'data'}
|
Copy to the clipboard
|
def encode(self):
return '{:.6f} {:.6f} {:.6f} {:.6f} {:.6f} {:.6f}'.format(
self.a, self.b, self.c, self.d, self.e, self.f
).encode()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '33']}; {'id': '8', 'type': 'attribute', 'children': ['9', '32']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'{:.6f} {:.6f} {:.6f} {:.6f} {:.6f} {:.6f}'"}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17', '20', '23', '26', '29']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '33', 'type': 'argument_list', 'children': []}
|
Encode this matrix in binary suitable for including in a PDF
|
def _autobounds(self):
bounds = {}
def check(prop, compare, extreme, val):
opp = min if compare is max else max
bounds.setdefault(prop, val)
bounds[prop] = opp(compare(bounds[prop], val), extreme)
def bound_check(lat_lon):
lat, lon = lat_lon
check('max_lat', max, 90, lat)
check('min_lat', min, -90, lat)
check('max_lon', max, 180, lon)
check('min_lon', min, -180, lon)
lat_lons = [lat_lon for feature in self._features.values() for
lat_lon in feature.lat_lons]
if not lat_lons:
lat_lons.append(self._default_lat_lon)
for lat_lon in lat_lons:
bound_check(lat_lon)
return bounds
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_autobounds'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '51', '96', '115', '128', '137']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'function_definition', 'children': ['11', '12', '17']}; {'id': '11', 'type': 'function_name', 'children': [], 'value': 'check'}; {'id': '12', 'type': 'parameters', 'children': ['13', '14', '15', '16']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'compare'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'extreme'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '17', 'type': 'block', 'children': ['18', '27', '35']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'opp'}; {'id': '21', 'type': 'conditional_expression', 'children': ['22', '23', '26'], 'value': 'if'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'is'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'compare'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'opp'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '50']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'compare'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'extreme'}; {'id': '51', 'type': 'function_definition', 'children': ['52', '53', '55']}; {'id': '52', 'type': 'function_name', 'children': [], 'value': 'bound_check'}; {'id': '53', 'type': 'parameters', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'lat_lon'}; {'id': '55', 'type': 'block', 'children': ['56', '62', '70', '79', '87']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '61']}; {'id': '58', 'type': 'pattern_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'lat_lon'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68', '69']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'max_lat'"}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '90'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75', '76', '78']}; {'id': '74', 'type': 'string', 'children': [], 'value': "'min_lat'"}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '76', 'type': 'unary_operator', 'children': ['77'], 'value': '-'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '90'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84', '85', '86']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'max_lon'"}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '180'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92', '93', '95']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'min_lon'"}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '93', 'type': 'unary_operator', 'children': ['94'], 'value': '-'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '180'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'lat_lons'}; {'id': '99', 'type': 'list_comprehension', 'children': ['100', '101', '110']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'lat_lon'}; {'id': '101', 'type': 'for_in_clause', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '103', 'type': 'call', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': '_features'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '109', 'type': 'argument_list', 'children': []}; {'id': '110', 'type': 'for_in_clause', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'lat_lon'}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'lat_lons'}; {'id': '115', 'type': 'if_statement', 'children': ['116', '118']}; {'id': '116', 'type': 'not_operator', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'lat_lons'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'lat_lons'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': '_default_lat_lon'}; {'id': '128', 'type': 'for_statement', 'children': ['129', '130', '131']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'lat_lon'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'lat_lons'}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'bound_check'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'lat_lon'}; {'id': '137', 'type': 'return_statement', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'bounds'}
|
Simple calculation for bounds.
|
def nvrtcCreateProgram(self, src, name, headers, include_names):
res = c_void_p()
headers_array = (c_char_p * len(headers))()
headers_array[:] = encode_str_list(headers)
include_names_array = (c_char_p * len(include_names))()
include_names_array[:] = encode_str_list(include_names)
code = self._lib.nvrtcCreateProgram(byref(res),
c_char_p(encode_str(src)), c_char_p(encode_str(name)),
len(headers),
headers_array, include_names_array)
self._throw_on_error(code)
return res
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nvrtcCreateProgram'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'include_names'}; {'id': '9', 'type': 'block', 'children': ['10', '16', '28', '38', '50', '60', '94', '101']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'c_void_p'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'headers_array'}; {'id': '19', 'type': 'call', 'children': ['20', '27']}; {'id': '20', 'type': '()', 'children': ['21']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '*'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'c_char_p'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '34']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'headers_array'}; {'id': '32', 'type': 'slice', 'children': ['33']}; {'id': '33', 'type': 'colon', 'children': []}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'encode_str_list'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'include_names_array'}; {'id': '41', 'type': 'call', 'children': ['42', '49']}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '*'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'c_char_p'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'include_names'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '56']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'include_names_array'}; {'id': '54', 'type': 'slice', 'children': ['55']}; {'id': '55', 'type': 'colon', 'children': []}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'encode_str_list'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'include_names'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '63', 'type': 'call', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_lib'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'nvrtcCreateProgram'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '74', '81', '88', '92', '93']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'byref'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'c_char_p'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'encode_str'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'c_char_p'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'encode_str'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'headers_array'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'include_names_array'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': '_throw_on_error'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '101', 'type': 'return_statement', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'res'}
|
Creates and returns a new NVRTC program object.
|
def _extract_file(zip_fp, info, path):
zip_fp.extract(info.filename, path=path)
out_path = os.path.join(path, info.filename)
perm = info.external_attr >> 16
perm |= stat.S_IREAD
os.chmod(out_path, perm)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_extract_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'zip_fp'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '34', '42', '48']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'zip_fp'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'extract'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'out_path'}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'perm'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '41'], 'value': '>>'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'external_attr'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'augmented_assignment', 'children': ['44', '45'], 'value': '|='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'perm'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'S_IREAD'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'chmod'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'out_path'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'perm'}
|
Extract files while explicitly setting the proper permissions
|
def _generate_standard_transitions(cls):
allowed_transitions = cls.context.get_config('transitions', {})
for key, transitions in allowed_transitions.items():
key = cls.context.new_meta['translator'].translate(key)
new_transitions = set()
for trans in transitions:
if not isinstance(trans, Enum):
trans = cls.context.new_meta['translator'].translate(trans)
new_transitions.add(trans)
cls.context.new_transitions[key] = new_transitions
for state in cls.context.states_enum:
if state not in cls.context.new_transitions:
cls.context.new_transitions[state] = set()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_standard_transitions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '93']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'allowed_transitions'}; {'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': 'cls'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_config'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'transitions'"}; {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'for_statement', 'children': ['19', '22', '27']}; {'id': '19', 'type': 'pattern_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'transitions'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'allowed_transitions'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28', '43', '49', '83']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '31', 'type': 'call', 'children': ['32', '41']}; {'id': '32', 'type': 'attribute', 'children': ['33', '40']}; {'id': '33', 'type': 'subscript', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'new_meta'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'translator'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'translate'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'new_transitions'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '52']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'transitions'}; {'id': '52', 'type': 'block', 'children': ['53', '76']}; {'id': '53', 'type': 'if_statement', 'children': ['54', '60']}; {'id': '54', 'type': 'not_operator', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'Enum'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '64', 'type': 'call', 'children': ['65', '74']}; {'id': '65', 'type': 'attribute', 'children': ['66', '73']}; {'id': '66', 'type': 'subscript', 'children': ['67', '72']}; {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'new_meta'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'translator'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'translate'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'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': 'new_transitions'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'trans'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '92']}; {'id': '85', 'type': 'subscript', 'children': ['86', '91']}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'new_transitions'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'new_transitions'}; {'id': '93', 'type': 'for_statement', 'children': ['94', '95', '100']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '95', 'type': 'attribute', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'states_enum'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'if_statement', 'children': ['102', '109']}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': 'not in'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'new_transitions'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '119']}; {'id': '112', 'type': 'subscript', 'children': ['113', '118']}; {'id': '113', 'type': 'attribute', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'new_transitions'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '121', 'type': 'argument_list', 'children': []}
|
Generate methods used for transitions.
|
def setOverlayDualAnalogTransform(self, ulOverlay, eWhich, fRadius):
fn = self.function_table.setOverlayDualAnalogTransform
pvCenter = HmdVector2_t()
result = fn(ulOverlay, eWhich, byref(pvCenter), fRadius)
return result, pvCenter
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setOverlayDualAnalogTransform'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ulOverlay'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'eWhich'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fRadius'}; {'id': '8', 'type': 'block', 'children': ['9', '17', '23', '36']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'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': 'function_table'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'setOverlayDualAnalogTransform'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pvCenter'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'HmdVector2_t'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'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', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '31', '35']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ulOverlay'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'eWhich'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'byref'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pvCenter'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'fRadius'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'expression_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'pvCenter'}
|
Sets the analog input to Dual Analog coordinate scale for the specified overlay.
|
def _job_statistics(self):
statistics = self._properties.get("statistics", {})
return statistics.get(self._JOB_TYPE, {})
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_job_statistics'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'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': 'statistics'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_properties'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"statistics"'}; {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'statistics'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_JOB_TYPE'}; {'id': '27', 'type': 'dictionary', 'children': []}
|
Helper for job-type specific statistics-based properties.
|
def prune_missing(table):
try:
for item in table.select():
if not os.path.isfile(item.file_path):
logger.info("File disappeared: %s", item.file_path)
item.delete()
except:
logger.exception("Error pruning %s", table)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prune_missing'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '45']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '15']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '28']}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '28', 'type': 'block', 'children': ['29', '39']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"File disappeared: %s"'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'except_clause', 'children': ['46']}; {'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': 'logger'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"Error pruning %s"'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'table'}
|
Prune any files which are missing from the specified table
|
def list_themes_user():
themes = [*os.scandir(os.path.join(CONF_DIR, "colorschemes/dark/")),
*os.scandir(os.path.join(CONF_DIR, "colorschemes/light/"))]
return [t for t in themes if os.path.isfile(t.path)]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_themes_user'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '39']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'themes'}; {'id': '8', 'type': 'list', 'children': ['9', '24'], 'value': '[*os.scandir(os.path.join(CONF_DIR, "colorschemes/dark/")),\n *os.scandir(os.path.join(CONF_DIR, "colorschemes/light/"))]'}; {'id': '9', 'type': 'list_splat', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'scandir'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'CONF_DIR'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"colorschemes/dark/"'}; {'id': '24', 'type': 'list_splat', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'scandir'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'CONF_DIR'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"colorschemes/light/"'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'list_comprehension', 'children': ['41', '42', '45']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'themes'}; {'id': '45', 'type': 'if_clause', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'path'}
|
List user theme files.
|
def degrees_of_freedom(self):
if len(self._set_xdata)==0 or len(self._set_ydata)==0: return None
r = self.studentized_residuals()
if r == None: return
N = 0.0
for i in range(len(r)): N += len(r[i])
return N-len(self._pnames)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'degrees_of_freedom'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '27', '35', '41', '45', '64']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '24']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '16'], 'value': 'or'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '15'], 'value': '=='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_set_xdata'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '23'], 'value': '=='}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_set_ydata'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'r'}; {'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': 'studentized_residuals'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '39']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': '=='}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': []}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '44', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '45', 'type': 'for_statement', 'children': ['46', '47', '54']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'augmented_assignment', 'children': ['57', '58'], 'value': '+='}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '-'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_pnames'}
|
Returns the number of degrees of freedom.
|
def description(self):
result = self.query.result()
return [field for field in result.schema]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'description'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'list_comprehension', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '19', 'type': 'for_in_clause', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'schema'}
|
Get the fields of the result set's schema.
|
def add_image_info_cb(self, gshell, channel, iminfo):
timestamp = iminfo.time_modified
if timestamp is None:
return
self.add_entry(channel.name, iminfo)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_image_info_cb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'gshell'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'iminfo'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '21']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'iminfo'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'time_modified'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'is'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'add_entry'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'iminfo'}
|
Add entries related to an added image.
|
def spell_check_no_pipeline(self, sources, options, personal_dict):
for source in sources:
if source._has_error():
yield Results([], source.context, source.category, source.error)
cmd = self.setup_command(source.encoding, options, personal_dict, source.context)
self.log('', 3)
self.log("Command: " + str(cmd), 4)
try:
wordlist = util.call_spellchecker(cmd, input_text=None, encoding=source.encoding)
yield Results(
[w for w in sorted(set(wordlist.replace('\r', '').split('\n'))) if w],
source.context,
source.category
)
except Exception as e:
err = self.get_error(e)
yield Results([], source.context, source.category, err)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spell_check_no_pipeline'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'personal_dict'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '12']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '12', 'type': 'block', 'children': ['13', '35', '51', '59', '72']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '19']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_has_error'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'yield', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Results'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '29', '32']}; {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'setup_command'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46', '47', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'personal_dict'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'string', 'children': [], 'value': "''"}; {'id': '58', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'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': 'log'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '71']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '+'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"Command: "'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '72', 'type': 'try_statement', 'children': ['73', '126']}; {'id': '73', 'type': 'block', 'children': ['74', '91']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'wordlist'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'call_spellchecker'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83', '86']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'input_text'}; {'id': '85', 'type': 'None', 'children': []}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'yield', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'Results'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '120', '123']}; {'id': '96', 'type': 'list_comprehension', 'children': ['97', '98', '118']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '98', 'type': 'for_in_clause', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '116']}; {'id': '107', 'type': 'attribute', 'children': ['108', '115']}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'wordlist'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114']}; {'id': '113', 'type': 'string', 'children': [], 'value': "'\\r'"}; {'id': '114', 'type': 'string', 'children': [], 'value': "''"}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '118', 'type': 'if_clause', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '126', 'type': 'except_clause', 'children': ['127', '131']}; {'id': '127', 'type': 'as_pattern', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '129', 'type': 'as_pattern_target', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '131', 'type': 'block', 'children': ['132', '141']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'get_error'}; {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'yield', 'children': ['143']}; {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'Results'}; {'id': '145', 'type': 'argument_list', 'children': ['146', '147', '150', '153']}; {'id': '146', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'err'}
|
Spell check without the pipeline.
|
def add_method(obj, func, name=None):
if name is None:
name = func.__name__
if sys.version_info < (3,):
method = types.MethodType(func, obj, obj.__class__)
else:
method = types.MethodType(func, obj)
setattr(obj, name, method)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_method'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '21', '54']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '28', '42']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': '<'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'version_info'}; {'id': '26', 'type': 'tuple', 'children': ['27']}; {'id': '27', 'type': 'integer', 'children': [], 'value': '3'}; {'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': 'method'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'MethodType'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38', '39']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '42', 'type': 'else_clause', 'children': ['43']}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'MethodType'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59', '60']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'method'}
|
Adds an instance method to an object.
|
def people(self):
people_response = self.get_request('people/')
return [Person(self, pjson['user']) for pjson in people_response]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'people'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'people_response'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_request'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'people/'"}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'list_comprehension', 'children': ['17', '24']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Person'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pjson'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '24', 'type': 'for_in_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'pjson'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'people_response'}
|
Generates a list of all People.
|
def enter_unlink_mode(self):
self.logger.info("enter_unlink_mode Group %s", self.group_id)
self.scene_command('0A')
status = self.hub.get_buffer_status()
return status
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'enter_unlink_mode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '25', '35']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"enter_unlink_mode Group %s"'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'group_id'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'scene_command'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'0A'"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'hub'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get_buffer_status'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'status'}
|
Enter unlinking mode for a group
|
def disable_radio_button(self):
checked = self.default_input_button_group.checkedButton()
if checked:
self.default_input_button_group.setExclusive(False)
checked.setChecked(False)
self.default_input_button_group.setExclusive(True)
for button in self.default_input_button_group.buttons():
button.setDisabled(True)
self.custom_value.setDisabled(True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'disable_radio_button'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '44', '61']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'default_input_button_group'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'checkedButton'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '18', 'type': 'block', 'children': ['19', '28', '35']}; {'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': 'default_input_button_group'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'setExclusive'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'False', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'setChecked'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'default_input_button_group'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'setExclusive'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'True', 'children': []}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '53']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'button'}; {'id': '46', 'type': 'call', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'default_input_button_group'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'buttons'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'button'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'setDisabled'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'True', 'children': []}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'custom_value'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'setDisabled'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'True', 'children': []}
|
Disable radio button group and custom value input area.
|
def trim(sequences, start, end):
logging.info("Trimming from %d to %d", start, end)
return (sequence[start:end] for sequence in sequences)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trim'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sequences'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '7', 'type': 'block', 'children': ['8', '17']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"Trimming from %d to %d"'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'generator_expression', 'children': ['19', '25']}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '21', 'type': 'slice', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '23', 'type': 'colon', 'children': []}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sequences'}
|
Slice the input sequences from start to end
|
def utc_book_close_time(self):
tz = pytz.timezone(self.timezone)
close_time = datetime.datetime.strptime(self.close_time, '%H:%M:%S').time()
close_time = tz.localize(datetime.datetime.combine(datetime.datetime.now(tz), close_time))
return close_time.astimezone(pytz.utc).time()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'utc_book_close_time'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '35', '59']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pytz'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'timezone'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'timezone'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'close_time'}; {'id': '20', 'type': 'call', 'children': ['21', '34']}; {'id': '21', 'type': 'attribute', 'children': ['22', '33']}; {'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': 'datetime'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'strptime'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'close_time'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'%H:%M:%S'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'close_time'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'localize'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'combine'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '58']}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'close_time'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '71']}; {'id': '61', 'type': 'attribute', 'children': ['62', '70']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'close_time'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'astimezone'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'pytz'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'utc'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '71', 'type': 'argument_list', 'children': []}
|
The book close time in utc.
|
def _get_geocoding(self, key, location):
url = self._location_query_base % quote_plus(key)
if self.api_key:
url += "&key=%s" % self.api_key
data = self._read_from_url(url)
response = json.loads(data)
if response["status"] == "OK":
formatted_address = response["results"][0]["formatted_address"]
pos = formatted_address.find(",")
if pos == -1:
location.name = formatted_address
location.region = ""
else:
location.name = formatted_address[:pos].strip()
location.region = formatted_address[pos + 1 :].strip()
geo_location = response["results"][0]["geometry"]["location"]
location.latitude = float(geo_location["lat"])
location.longitude = float(geo_location["lng"])
else:
raise AstralError("GoogleGeocoder: Unable to locate %s. Server Response=%s" %
(key, response["status"]))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_geocoding'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '32', '41', '50']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '11', 'type': 'binary_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': '_location_query_base'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'quote_plus'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'api_key'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'augmented_assignment', 'children': ['26', '27'], 'value': '+='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '%'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"&key=%s"'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'api_key'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_read_from_url'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'response'}; {'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': 'data'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '56', '160']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': '=='}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '54', 'type': 'string', 'children': [], 'value': '"status"'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"OK"'}; {'id': '56', 'type': 'block', 'children': ['57', '67', '76', '126', '138', '149']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'formatted_address'}; {'id': '60', 'type': 'subscript', 'children': ['61', '66']}; {'id': '61', 'type': 'subscript', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"results"'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"formatted_address"'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'formatted_address'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'string', 'children': [], 'value': '","'}; {'id': '76', 'type': 'if_statement', 'children': ['77', '81', '94']}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '79'], 'value': '=='}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '79', 'type': 'unary_operator', 'children': ['80'], 'value': '-'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '81', 'type': 'block', 'children': ['82', '88']}; {'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': 'location'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'formatted_address'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '93', 'type': 'string', 'children': [], 'value': '""'}; {'id': '94', 'type': 'else_clause', 'children': ['95']}; {'id': '95', 'type': 'block', 'children': ['96', '110']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '101', 'type': 'call', 'children': ['102', '109']}; {'id': '102', 'type': 'attribute', 'children': ['103', '108']}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'formatted_address'}; {'id': '105', 'type': 'slice', 'children': ['106', '107']}; {'id': '106', 'type': 'colon', 'children': []}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '109', 'type': 'argument_list', 'children': []}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '115', 'type': 'call', 'children': ['116', '125']}; {'id': '116', 'type': 'attribute', 'children': ['117', '124']}; {'id': '117', 'type': 'subscript', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'formatted_address'}; {'id': '119', 'type': 'slice', 'children': ['120', '123']}; {'id': '120', 'type': 'binary_operator', 'children': ['121', '122'], 'value': '+'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '122', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '123', 'type': 'colon', 'children': []}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '125', 'type': 'argument_list', 'children': []}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'geo_location'}; {'id': '129', 'type': 'subscript', 'children': ['130', '137']}; {'id': '130', 'type': 'subscript', 'children': ['131', '136']}; {'id': '131', 'type': 'subscript', 'children': ['132', '135']}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '134', 'type': 'string', 'children': [], 'value': '"results"'}; {'id': '135', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '136', 'type': 'string', 'children': [], 'value': '"geometry"'}; {'id': '137', 'type': 'string', 'children': [], 'value': '"location"'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'latitude'}; {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'subscript', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'geo_location'}; {'id': '148', 'type': 'string', 'children': [], 'value': '"lat"'}; {'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': 'location'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'longitude'}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'subscript', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'geo_location'}; {'id': '159', 'type': 'string', 'children': [], 'value': '"lng"'}; {'id': '160', 'type': 'else_clause', 'children': ['161']}; {'id': '161', 'type': 'block', 'children': ['162']}; {'id': '162', 'type': 'raise_statement', 'children': ['163']}; {'id': '163', 'type': 'call', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'AstralError'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'binary_operator', 'children': ['167', '168'], 'value': '%'}; {'id': '167', 'type': 'string', 'children': [], 'value': '"GoogleGeocoder: Unable to locate %s. Server Response=%s"'}; {'id': '168', 'type': 'tuple', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '170', 'type': 'subscript', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '172', 'type': 'string', 'children': [], 'value': '"status"'}
|
Lookup the Google geocoding API information for `key`
|
def all(self, query=None, **kwargs):
if query is None:
query = {}
normalize_select(query)
return super(AssetsProxy, self).all(query, **kwargs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all'}; {'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': 'query'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '20', '25']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '19', 'type': 'dictionary', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'normalize_select'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '34']}; {'id': '27', 'type': 'attribute', 'children': ['28', '33']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'AssetsProxy'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '36', 'type': 'dictionary_splat', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Gets all assets of a space.
|
def make_gtp_instance(load_file, cgos_mode=False, kgs_mode=False,
minigui_mode=False):
n = DualNetwork(load_file)
if cgos_mode:
player = CGOSPlayer(network=n, seconds_per_move=5, timed_match=True,
two_player_mode=True)
else:
player = MCTSPlayer(network=n, two_player_mode=True)
name = "Minigo-" + os.path.basename(load_file)
version = "0.2"
engine = gtp_engine.Engine()
engine.add_cmd_handler(
gtp_engine.EngineCmdHandler(engine, name, version))
if kgs_mode:
engine.add_cmd_handler(KgsCmdHandler(player))
engine.add_cmd_handler(RegressionsCmdHandler(player))
engine.add_cmd_handler(GoGuiCmdHandler(player))
if minigui_mode:
engine.add_cmd_handler(MiniguiBasicCmdHandler(player, courtesy_pass=kgs_mode))
else:
engine.add_cmd_handler(BasicCmdHandler(player, courtesy_pass=kgs_mode))
return engine
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_gtp_instance'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'load_file'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cgos_mode'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kgs_mode'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'minigui_mode'}; {'id': '13', 'type': 'False', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '22', '57', '70', '74', '82', '96', '109', '119', '129', '160']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'DualNetwork'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'load_file'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '24', '43']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cgos_mode'}; {'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': 'player'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'CGOSPlayer'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34', '37', '40']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'seconds_per_move'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'timed_match'}; {'id': '39', 'type': 'True', 'children': []}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'two_player_mode'}; {'id': '42', 'type': 'True', 'children': []}; {'id': '43', 'type': 'else_clause', 'children': ['44']}; {'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': 'player'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'MCTSPlayer'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '54']}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'two_player_mode'}; {'id': '56', 'type': 'True', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '+'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"Minigo-"'}; {'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': 'os'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'load_file'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '73', 'type': 'string', 'children': [], 'value': '"0.2"'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'gtp_engine'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'Engine'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'add_cmd_handler'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'gtp_engine'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'EngineCmdHandler'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94', '95']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '96', 'type': 'if_statement', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'kgs_mode'}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'add_cmd_handler'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'KgsCmdHandler'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'player'}; {'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': 'engine'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'add_cmd_handler'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'RegressionsCmdHandler'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'player'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'add_cmd_handler'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'GoGuiCmdHandler'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'player'}; {'id': '129', 'type': 'if_statement', 'children': ['130', '131', '145']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'minigui_mode'}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'add_cmd_handler'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'MiniguiBasicCmdHandler'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'player'}; {'id': '142', 'type': 'keyword_argument', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'courtesy_pass'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'kgs_mode'}; {'id': '145', 'type': 'else_clause', 'children': ['146']}; {'id': '146', 'type': 'block', 'children': ['147']}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'add_cmd_handler'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}; {'id': '153', 'type': 'call', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'BasicCmdHandler'}; {'id': '155', 'type': 'argument_list', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'player'}; {'id': '157', 'type': 'keyword_argument', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'courtesy_pass'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'kgs_mode'}; {'id': '160', 'type': 'return_statement', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'engine'}
|
Takes a path to model files and set up a GTP engine instance.
|
def install(path, remove=False, prefix=sys.prefix, recursing=False):
if sys.platform == 'win32' and not exists(join(sys.prefix, '.nonadmin')):
if isUserAdmin():
_install(path, remove, prefix, mode='system')
else:
from pywintypes import error
try:
if not recursing:
retcode = runAsAdmin([join(sys.prefix, 'python'), '-c',
"import menuinst; menuinst.install(%r, %r, %r, %r)" % (
path, bool(remove), prefix, True)])
else:
retcode = 1
except error:
retcode = 1
if retcode != 0:
logging.warn("Insufficient permissions to write menu folder. "
"Falling back to user location")
_install(path, remove, prefix, mode='user')
else:
_install(path, remove, prefix, mode='user')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '13']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'recursing'}; {'id': '15', 'type': 'False', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '35', '126']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '24'], 'value': 'and'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '23'], 'value': '=='}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'win32'"}; {'id': '24', 'type': 'not_operator', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'.nonadmin'"}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40', '51']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'isUserAdmin'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_install'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46', '47', '48']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'system'"}; {'id': '51', 'type': 'else_clause', 'children': ['52']}; {'id': '52', 'type': 'block', 'children': ['53', '58', '102']}; {'id': '53', 'type': 'import_from_statement', 'children': ['54', '56']}; {'id': '54', 'type': 'dotted_name', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pywintypes'}; {'id': '56', 'type': 'dotted_name', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '58', 'type': 'try_statement', 'children': ['59', '95']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'if_statement', 'children': ['61', '63', '89']}; {'id': '61', 'type': 'not_operator', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'recursing'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'retcode'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'runAsAdmin'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'list', 'children': ['71', '78', '79'], 'value': '[join(sys.prefix, \'python\'), \'-c\',\n "import menuinst; menuinst.install(%r, %r, %r, %r)" % (\n path, bool(remove), prefix, True)]'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'python'"}; {'id': '78', 'type': 'string', 'children': [], 'value': "'-c'"}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '81'], 'value': '%'}; {'id': '80', 'type': 'string', 'children': [], 'value': '"import menuinst; menuinst.install(%r, %r, %r, %r)"'}; {'id': '81', 'type': 'tuple', 'children': ['82', '83', '87', '88']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '88', 'type': 'True', 'children': []}; {'id': '89', 'type': 'else_clause', 'children': ['90']}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'retcode'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '95', 'type': 'except_clause', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'retcode'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '106']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '105'], 'value': '!='}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'retcode'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '106', 'type': 'block', 'children': ['107', '116']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'concatenated_string', 'children': ['114', '115']}; {'id': '114', 'type': 'string', 'children': [], 'value': '"Insufficient permissions to write menu folder. "'}; {'id': '115', 'type': 'string', 'children': [], 'value': '"Falling back to user location"'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': '_install'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '121', '122', '123']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '123', 'type': 'keyword_argument', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '125', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '126', 'type': 'else_clause', 'children': ['127']}; {'id': '127', 'type': 'block', 'children': ['128']}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '_install'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '133', '134', '135']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '135', 'type': 'keyword_argument', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '137', 'type': 'string', 'children': [], 'value': "'user'"}
|
install Menu and shortcuts
|
def _parse_comma_list(self):
if self._cur_token['type'] not in self._literals:
raise Exception(
"Parser failed, _parse_comma_list was called on non-literal"
" {} on line {}.".format(
repr(self._cur_token['value']), self._cur_token['line']
)
)
array = []
while self._cur_token['type'] in self._literals and not self._finished:
array.append(self._cur_token['value'])
self._increment()
self._skip_whitespace()
if self._cur_token['type'] is TT.comma:
self._increment()
self._skip_whitespace()
elif (
not self._finished and
self._cur_token['type'] not in (TT.ws, TT.lbreak)
):
raise ParseError('comma or newline', self._cur_token)
return array
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_comma_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '41', '45', '136']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '13'], 'value': 'not in'}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_literals'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'raise_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'concatenated_string', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"Parser failed, _parse_comma_list was called on non-literal"'}; {'id': '25', 'type': 'string', 'children': [], 'value': '" {} on line {}."'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '36']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'line'"}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '44', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '45', 'type': 'while_statement', 'children': ['46', '60']}; {'id': '46', 'type': 'boolean_operator', 'children': ['47', '56'], 'value': 'and'}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '53'], 'value': 'in'}; {'id': '48', 'type': 'subscript', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_literals'}; {'id': '56', 'type': 'not_operator', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_finished'}; {'id': '60', 'type': 'block', 'children': ['61', '72', '78', '84']}; {'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': 'array'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'subscript', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_increment'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_skip_whitespace'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'if_statement', 'children': ['85', '94', '107']}; {'id': '85', 'type': 'comparison_operator', 'children': ['86', '91'], 'value': 'is'}; {'id': '86', 'type': 'subscript', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '90', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'TT'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'comma'}; {'id': '94', 'type': 'block', 'children': ['95', '101']}; {'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': '_increment'}; {'id': '100', 'type': 'argument_list', 'children': []}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': '_skip_whitespace'}; {'id': '106', 'type': 'argument_list', 'children': []}; {'id': '107', 'type': 'elif_clause', 'children': ['108', '127']}; {'id': '108', 'type': '()', 'children': ['109']}; {'id': '109', 'type': 'boolean_operator', 'children': ['110', '114'], 'value': 'and'}; {'id': '110', 'type': 'not_operator', 'children': ['111']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': '_finished'}; {'id': '114', 'type': 'comparison_operator', 'children': ['115', '120'], 'value': 'not in'}; {'id': '115', 'type': 'subscript', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '119', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '120', 'type': 'tuple', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'TT'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'ws'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'TT'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'lbreak'}; {'id': '127', 'type': 'block', 'children': ['128']}; {'id': '128', 'type': 'raise_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'ParseError'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '133']}; {'id': '132', 'type': 'string', 'children': [], 'value': "'comma or newline'"}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': '_cur_token'}; {'id': '136', 'type': 'return_statement', 'children': ['137']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'array'}
|
Parse a comma seperated list.
|
def add_class2fields(self, html_class, fields=[], exclude=[], include_all_if_empty=True):
self.add_attr2fields('class', html_class, fields, exclude)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_class2fields'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'html_class'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '8', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'exclude'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'include_all_if_empty'}; {'id': '14', 'type': 'True', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'add_attr2fields'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '24', '25']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'class'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'html_class'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'exclude'}
|
add class to html widgets.
|
def show_filetypes(extensions):
for item in extensions.items():
val = item[1]
if type(item[1]) == list:
val = ", ".join(str(x) for x in item[1])
print("{0:4}: {1}".format(val, item[0]))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_filetypes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'extensions'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '13']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'extensions'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '20', '47']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '29']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '28'], 'value': '=='}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'list'}; {'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': 'val'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '37', 'type': 'generator_expression', 'children': ['38', '42']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"{0:4}: {1}"'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}
|
function to show valid file extensions
|
def in_cmd(argv):
if len(argv) == 1:
return workon_cmd(argv)
parse_envname(argv, lambda : sys.exit('You must provide a valid virtualenv to target'))
return inve(*argv)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'in_cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '31']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '12'], 'value': '=='}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'workon_cmd'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'parse_envname'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '24', 'type': 'lambda', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'You must provide a valid virtualenv to target'"}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'inve'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'list_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'argv'}
|
Run a command in the given virtualenv.
|
def getOntology(self, id_):
if id_ not in self._ontologyIdMap:
raise exceptions.OntologyNotFoundException(id_)
return self._ontologyIdMap[id_]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getOntology'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '6', 'type': 'block', 'children': ['7', '21']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'not in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_ontologyIdMap'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'raise_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'OntologyNotFoundException'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'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': '_ontologyIdMap'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'id_'}
|
Returns the ontology with the specified ID.
|
def _make_matchers(self, crontab):
crontab = _aliases.get(crontab, crontab)
ct = crontab.split()
if len(ct) == 5:
ct.insert(0, '0')
ct.append('*')
elif len(ct) == 6:
ct.insert(0, '0')
_assert(len(ct) == 7,
"improper number of cron entries specified; got %i need 5 to 7"%(len(ct,)))
matchers = [_Matcher(which, entry) for which, entry in enumerate(ct)]
return Matcher(*matchers)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_matchers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'crontab'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '25', '64', '81', '98']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'crontab'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_aliases'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'crontab'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'crontab'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'crontab'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '32', '48']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '31'], 'value': '=='}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '32', 'type': 'block', 'children': ['33', '41']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'0'"}; {'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': 'ct'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '48', 'type': 'elif_clause', 'children': ['49', '55']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '54'], 'value': '=='}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'0'"}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_assert'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '74']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '73'], 'value': '=='}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '76'], 'value': '%'}; {'id': '75', 'type': 'string', 'children': [], 'value': '"improper number of cron entries specified; got %i need 5 to 7"'}; {'id': '76', 'type': '()', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'matchers'}; {'id': '84', 'type': 'list_comprehension', 'children': ['85', '90']}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_Matcher'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'which'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '90', 'type': 'for_in_clause', 'children': ['91', '94']}; {'id': '91', 'type': 'pattern_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'which'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'Matcher'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'list_splat', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'matchers'}
|
This constructs the full matcher struct.
|
def _clean_kwargs(keep_name=False, **kwargs):
if 'name' in kwargs and not keep_name:
kwargs['name_or_id'] = kwargs.pop('name')
return __utils__['args.clean_kwargs'](**kwargs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_clean_kwargs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'keep_name'}; {'id': '6', 'type': 'False', 'children': []}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '29']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '17']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '15'], 'value': 'and'}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'keep_name'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'name_or_id'"}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '__utils__'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'args.clean_kwargs'"}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'dictionary_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Sanatize the the arguments for use with shade
|
async def model_uuids(self):
controller_facade = client.ControllerFacade.from_connection(
self.connection())
for attempt in (1, 2, 3):
try:
response = await controller_facade.AllModels()
return {um.model.name: um.model.uuid
for um in response.user_models}
except errors.JujuAPIError as e:
if 'has been removed' not in e.message or attempt == 3:
raise
await asyncio.sleep(attempt, loop=self._connector.loop)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'model_uuids'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'controller_facade'}; {'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': 'client'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ControllerFacade'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'from_connection'}; {'id': '15', 'type': 'argument_list', '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': 'connection'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '27']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'attempt'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'try_statement', 'children': ['29', '57']}; {'id': '29', 'type': 'block', 'children': ['30', '39']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '33', 'type': 'await', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'controller_facade'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'AllModels'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'dictionary_comprehension', 'children': ['41', '52']}; {'id': '41', 'type': 'pair', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'um'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'um'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '52', 'type': 'for_in_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'um'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'user_models'}; {'id': '57', 'type': 'except_clause', 'children': ['58', '64']}; {'id': '58', 'type': 'as_pattern', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'JujuAPIError'}; {'id': '62', 'type': 'as_pattern_target', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '64', 'type': 'block', 'children': ['65', '77']}; {'id': '65', 'type': 'if_statement', 'children': ['66', '75']}; {'id': '66', 'type': 'boolean_operator', 'children': ['67', '72'], 'value': 'or'}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': 'not in'}; {'id': '68', 'type': 'string', 'children': [], 'value': "'has been removed'"}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': '=='}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'attempt'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'raise_statement', 'children': []}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'await', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'attempt'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '87', 'type': 'attribute', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '_connector'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'loop'}
|
Return a mapping of model names to UUIDs.
|
def runs_to_xml(self, runSet, runs, blockname=None):
runsElem = util.copy_of_xml_element(self.xml_header)
runsElem.set("options", " ".join(runSet.options))
if blockname is not None:
runsElem.set("block", blockname)
runsElem.set("name", ((runSet.real_name + ".") if runSet.real_name else "") + blockname)
elif runSet.real_name:
runsElem.set("name", runSet.real_name)
for run in runs:
runsElem.append(run.xml)
return runsElem
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'runs_to_xml'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'runSet'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'blockname'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '22', '37', '86', '99']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'runsElem'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'copy_of_xml_element'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'xml_header'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'runsElem'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"options"'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'runSet'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '41', '71']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': 'is not'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'blockname'}; {'id': '40', 'type': 'None', 'children': []}; {'id': '41', 'type': 'block', 'children': ['42', '50']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'runsElem'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"block"'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'blockname'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'runsElem'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '70'], 'value': '+'}; {'id': '58', 'type': '()', 'children': ['59']}; {'id': '59', 'type': 'conditional_expression', 'children': ['60', '66', '69'], 'value': 'if'}; {'id': '60', 'type': '()', 'children': ['61']}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '65'], 'value': '+'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'runSet'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'real_name'}; {'id': '65', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'runSet'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'real_name'}; {'id': '69', 'type': 'string', 'children': [], 'value': '""'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'blockname'}; {'id': '71', 'type': 'elif_clause', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'runSet'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'real_name'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'runsElem'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'runSet'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'real_name'}; {'id': '86', 'type': 'for_statement', 'children': ['87', '88', '89']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'runsElem'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'xml'}; {'id': '99', 'type': 'return_statement', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'runsElem'}
|
This function creates the XML structure for a list of runs
|
def soap_attribute(self, name, value):
setattr(self, name, value)
self._attributes.add(name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'soap_attribute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8', '15']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_attributes'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Marks an attribute as being a part of the data defined by the soap datatype
|
def _validate_changeset(self, changeset_id: uuid.UUID) -> None:
if not self.journal.has_changeset(changeset_id):
raise ValidationError("Changeset not found in journal: {0}".format(
str(changeset_id)
))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_changeset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'changeset_id'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'UUID'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '24']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'journal'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'has_changeset'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'changeset_id'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ValidationError'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"Changeset not found in journal: {0}"'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'changeset_id'}
|
Checks to be sure the changeset is known by the journal
|
def process_request_thread(self, mainthread):
life_time = time.time()
nb_requests = 0
while not mainthread.killed():
if self.max_life_time > 0:
if (time.time() - life_time) >= self.max_life_time:
mainthread.add_worker(1)
return
try:
SocketServer.ThreadingTCPServer.process_request_thread(self, *self.requests.get(True, 0.5))
except Queue.Empty:
continue
else:
SocketServer.ThreadingTCPServer.process_request_thread(self, *self.requests.get())
LOG.debug("nb_requests: %d, max_requests: %d", nb_requests, self.max_requests)
nb_requests += 1
if self.max_requests > 0 and nb_requests >= self.max_requests:
mainthread.add_worker(1)
return
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_request_thread'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mainthread'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'life_time'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'time'}; {'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': 'nb_requests'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'while_statement', 'children': ['20', '26']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'mainthread'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'killed'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27', '102', '113', '117']}; {'id': '27', 'type': 'if_statement', 'children': ['28', '33', '83']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': '>'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'max_life_time'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'block', 'children': ['34', '56']}; {'id': '34', 'type': 'if_statement', 'children': ['35', '47']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '44'], 'value': '>='}; {'id': '36', 'type': '()', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '43'], 'value': '-'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'life_time'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'max_life_time'}; {'id': '47', 'type': 'block', 'children': ['48', '55']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'mainthread'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'add_worker'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'return_statement', 'children': []}; {'id': '56', 'type': 'try_statement', 'children': ['57', '77']}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'SocketServer'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ThreadingTCPServer'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'process_request_thread'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'list_splat', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'True', 'children': []}; {'id': '76', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '77', 'type': 'except_clause', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'Queue'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'Empty'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'continue_statement', 'children': []}; {'id': '83', 'type': 'else_clause', 'children': ['84']}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '92']}; {'id': '87', 'type': 'attribute', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'SocketServer'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'ThreadingTCPServer'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'process_request_thread'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'list_splat', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '101']}; {'id': '96', 'type': 'attribute', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '101', 'type': 'argument_list', 'children': []}; {'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': 'LOG'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '107', 'type': 'argument_list', 'children': ['108', '109', '110']}; {'id': '108', 'type': 'string', 'children': [], 'value': '"nb_requests: %d, max_requests: %d"'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'nb_requests'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'max_requests'}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'augmented_assignment', 'children': ['115', '116'], 'value': '+='}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'nb_requests'}; {'id': '116', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '117', 'type': 'if_statement', 'children': ['118', '129']}; {'id': '118', 'type': 'boolean_operator', 'children': ['119', '124'], 'value': 'and'}; {'id': '119', 'type': 'comparison_operator', 'children': ['120', '123'], 'value': '>'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'max_requests'}; {'id': '123', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '124', 'type': 'comparison_operator', 'children': ['125', '126'], 'value': '>='}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'nb_requests'}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'max_requests'}; {'id': '129', 'type': 'block', 'children': ['130', '137']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'mainthread'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'add_worker'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '137', 'type': 'return_statement', 'children': []}
|
obtain request from queue instead of directly from server socket
|
def _make_sections(self, **section_hdr_params):
sect_story = []
if not self.section_headings and len(self.sections):
self.section_headings = self.sections.keys()
for section_name in self.section_headings:
section_story = self.sections[section_name]
line = '-'*20
section_head_text = '%s %s %s' % (line, section_name, line)
title, title_sp = self._preformat_text(section_head_text,
**section_hdr_params)
sect_story += [title, title_sp] + section_story
return sect_story
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_sections'}; {'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': 'section_hdr_params'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '37', '87']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sect_story'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '24']}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '18'], 'value': 'and'}; {'id': '14', 'type': 'not_operator', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'section_headings'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sections'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'section_headings'}; {'id': '30', 'type': 'call', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'sections'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '42']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'section_name'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'section_headings'}; {'id': '42', 'type': 'block', 'children': ['43', '51', '57', '66', '79']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'section_story'}; {'id': '46', 'type': 'subscript', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sections'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'section_name'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '*'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '56', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'section_head_text'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '%'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'%s %s %s'"}; {'id': '62', 'type': 'tuple', 'children': ['63', '64', '65']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'section_name'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '71']}; {'id': '68', 'type': 'pattern_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'title_sp'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_preformat_text'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'section_head_text'}; {'id': '77', 'type': 'dictionary_splat', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'section_hdr_params'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'augmented_assignment', 'children': ['81', '82'], 'value': '+='}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'sect_story'}; {'id': '82', 'type': 'binary_operator', 'children': ['83', '86'], 'value': '+'}; {'id': '83', 'type': 'list', 'children': ['84', '85'], 'value': '[title, title_sp]'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'title_sp'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'section_story'}; {'id': '87', 'type': 'return_statement', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sect_story'}
|
Flatten the sections into a single story list.
|
def getDict(self):
badList = self.checkSetSaveEntries(doSave=False)
if badList:
self.processBadEntries(badList, self.taskName, canCancel=False)
return self._taskParsObj.dict()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getDict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '33']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'badList'}; {'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': 'checkSetSaveEntries'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'doSave'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'if_statement', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'badList'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'processBadEntries'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '30']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'badList'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'taskName'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'canCancel'}; {'id': '32', 'type': 'False', 'children': []}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_taskParsObj'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '40', 'type': 'argument_list', 'children': []}
|
Retrieve the current parameter settings from the GUI.
|
def _get_events(self, result):
events = []
for event_data in result:
event = Event.factory(event_data)
if event is not None:
events.append(event)
if isinstance(event, DeviceStateChangedEvent):
if self.__devices[event.device_url] is None:
raise Exception(
"Received device change " +
"state for unknown device '" +
event.device_url + "'")
self.__devices[event.device_url].set_active_states(
event.states)
return events
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_events'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '82']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'event_data'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '14', 'type': 'block', 'children': ['15', '24']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'Event'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'factory'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'event_data'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'is not'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29', '36']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '42']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'DeviceStateChangedEvent'}; {'id': '42', 'type': 'block', 'children': ['43', '67']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '53']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '52'], 'value': 'is'}; {'id': '45', 'type': 'subscript', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '__devices'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'device_url'}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'raise_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '66'], 'value': '+'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '63'], 'value': '+'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '+'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"Received device change "'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"state for unknown device \'"'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'device_url'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"\'"'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '78']}; {'id': '69', 'type': 'attribute', 'children': ['70', '77']}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '__devices'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'device_url'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'set_active_states'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'states'}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'events'}
|
Internal method for being able to run unit tests.
|
def login():
if request.method == "POST":
username = request.form["username"]
password = request.form["password"]
error = None
user = User.query.filter_by(username=username).first()
if user is None:
error = "Incorrect username."
elif not user.check_password(password):
error = "Incorrect password."
if error is None:
session.clear()
session["user_id"] = user.id
return redirect(url_for("index"))
flash(error)
return render_template("auth/login.html")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'login'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '103']}; {'id': '5', 'type': 'if_statement', 'children': ['6', '11']}; {'id': '6', 'type': 'comparison_operator', 'children': ['7', '10'], 'value': '=='}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"POST"'}; {'id': '11', 'type': 'block', 'children': ['12', '20', '28', '32', '49', '71', '98']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '15', 'type': 'subscript', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"username"'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"password"'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '35', 'type': 'call', 'children': ['36', '48']}; {'id': '36', 'type': 'attribute', 'children': ['37', '47']}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'filter_by'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'if_statement', 'children': ['50', '53', '58']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': 'is'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"Incorrect username."'}; {'id': '58', 'type': 'elif_clause', 'children': ['59', '66']}; {'id': '59', 'type': 'not_operator', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'check_password'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'password'}; {'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': 'error'}; {'id': '70', 'type': 'string', 'children': [], 'value': '"Incorrect password."'}; {'id': '71', 'type': 'if_statement', 'children': ['72', '75']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': 'is'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '74', 'type': 'None', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76', '82', '90']}; {'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': 'session'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '87']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '86', 'type': 'string', 'children': [], 'value': '"user_id"'}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'redirect'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'url_for'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'string', 'children': [], 'value': '"index"'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'flash'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'render_template'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'string', 'children': [], 'value': '"auth/login.html"'}
|
Log in a registered user by adding the user id to the session.
|
def _number_type_helper(national_number, metadata):
if not _is_number_matching_desc(national_number, metadata.general_desc):
return PhoneNumberType.UNKNOWN
if _is_number_matching_desc(national_number, metadata.premium_rate):
return PhoneNumberType.PREMIUM_RATE
if _is_number_matching_desc(national_number, metadata.toll_free):
return PhoneNumberType.TOLL_FREE
if _is_number_matching_desc(national_number, metadata.shared_cost):
return PhoneNumberType.SHARED_COST
if _is_number_matching_desc(national_number, metadata.voip):
return PhoneNumberType.VOIP
if _is_number_matching_desc(national_number, metadata.personal_number):
return PhoneNumberType.PERSONAL_NUMBER
if _is_number_matching_desc(national_number, metadata.pager):
return PhoneNumberType.PAGER
if _is_number_matching_desc(national_number, metadata.uan):
return PhoneNumberType.UAN
if _is_number_matching_desc(national_number, metadata.voicemail):
return PhoneNumberType.VOICEMAIL
if _is_number_matching_desc(national_number, metadata.fixed_line):
if metadata.same_mobile_and_fixed_line_pattern:
return PhoneNumberType.FIXED_LINE_OR_MOBILE
elif _is_number_matching_desc(national_number, metadata.mobile):
return PhoneNumberType.FIXED_LINE_OR_MOBILE
return PhoneNumberType.FIXED_LINE
if (not metadata.same_mobile_and_fixed_line_pattern and
_is_number_matching_desc(national_number, metadata.mobile)):
return PhoneNumberType.MOBILE
return PhoneNumberType.UNKNOWN
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_number_type_helper'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '34', '47', '60', '73', '86', '99', '112', '125', '160', '179']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '16']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'general_desc'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'UNKNOWN'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '29']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'premium_rate'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'PREMIUM_RATE'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '42']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'toll_free'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'TOLL_FREE'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '55']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'shared_cost'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'SHARED_COST'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '68']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'voip'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'VOIP'}; {'id': '73', 'type': 'if_statement', 'children': ['74', '81']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'personal_number'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'PERSONAL_NUMBER'}; {'id': '86', 'type': 'if_statement', 'children': ['87', '94']}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'pager'}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'PAGER'}; {'id': '99', 'type': 'if_statement', 'children': ['100', '107']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'uan'}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'UAN'}; {'id': '112', 'type': 'if_statement', 'children': ['113', '120']}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'voicemail'}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'return_statement', 'children': ['122']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'VOICEMAIL'}; {'id': '125', 'type': 'if_statement', 'children': ['126', '133']}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'fixed_line'}; {'id': '133', 'type': 'block', 'children': ['134', '156']}; {'id': '134', 'type': 'if_statement', 'children': ['135', '138', '143']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'same_mobile_and_fixed_line_pattern'}; {'id': '138', 'type': 'block', 'children': ['139']}; {'id': '139', 'type': 'return_statement', 'children': ['140']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'FIXED_LINE_OR_MOBILE'}; {'id': '143', 'type': 'elif_clause', 'children': ['144', '151']}; {'id': '144', 'type': 'call', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '146', 'type': 'argument_list', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'mobile'}; {'id': '151', 'type': 'block', 'children': ['152']}; {'id': '152', 'type': 'return_statement', 'children': ['153']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'FIXED_LINE_OR_MOBILE'}; {'id': '156', 'type': 'return_statement', 'children': ['157']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'FIXED_LINE'}; {'id': '160', 'type': 'if_statement', 'children': ['161', '174']}; {'id': '161', 'type': '()', 'children': ['162']}; {'id': '162', 'type': 'boolean_operator', 'children': ['163', '167'], 'value': 'and'}; {'id': '163', 'type': 'not_operator', 'children': ['164']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'same_mobile_and_fixed_line_pattern'}; {'id': '167', 'type': 'call', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': '_is_number_matching_desc'}; {'id': '169', 'type': 'argument_list', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'national_number'}; {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'mobile'}; {'id': '174', 'type': 'block', 'children': ['175']}; {'id': '175', 'type': 'return_statement', 'children': ['176']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'MOBILE'}; {'id': '179', 'type': 'return_statement', 'children': ['180']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'PhoneNumberType'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'UNKNOWN'}
|
Return the type of the given number against the metadata
|
def _after_request(self, response):
if not getattr(g, '_has_exception', False):
extra = self.summary_extra()
self.summary_logger.info('', extra=extra)
return response
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_after_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '6', 'type': 'block', 'children': ['7', '36']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'_has_exception'"}; {'id': '14', 'type': 'False', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16', '24']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'summary_extra'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'summary_logger'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "''"}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'response'}
|
The signal handler for the request_finished signal.
|
def _write_recordio(f, data):
length = len(data)
f.write(struct.pack('I', _kmagic))
f.write(struct.pack('I', length))
pad = (((length + 3) >> 2) << 2) - length
f.write(data)
f.write(padding[pad])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write_recordio'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '27', '40', '55', '62']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'I'"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_kmagic'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'I'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pad'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '54'], 'value': '-'}; {'id': '44', 'type': '()', 'children': ['45']}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '53'], 'value': '<<'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '52'], 'value': '>>'}; {'id': '48', 'type': '()', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '+'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'length'}; {'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': 'f'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'padding'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pad'}
|
Writes a single data point as a RecordIO record to the given file.
|
def formatSubclassOf(fmt, cls, ontology, visited):
if URIRef(fmt) == URIRef(cls):
return True
if ontology is None:
return False
if fmt in visited:
return False
visited.add(fmt)
uriRefFmt = URIRef(fmt)
for s, p, o in ontology.triples((uriRefFmt, RDFS.subClassOf, None)):
if formatSubclassOf(o, cls, ontology, visited):
return True
for s, p, o in ontology.triples((uriRefFmt, OWL.equivalentClass, None)):
if formatSubclassOf(o, cls, ontology, visited):
return True
for s, p, o in ontology.triples((None, OWL.equivalentClass, uriRefFmt)):
if formatSubclassOf(s, cls, ontology, visited):
return True
return False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'formatSubclassOf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '8', 'type': 'block', 'children': ['9', '22', '29', '36', '43', '50', '78', '106', '134']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '19']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '15'], 'value': '=='}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'URIRef'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'URIRef'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'True', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'is'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'False', 'children': []}; {'id': '29', 'type': 'if_statement', 'children': ['30', '33']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'in'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'False', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'uriRefFmt'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'URIRef'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '50', 'type': 'for_statement', 'children': ['51', '55', '66']}; {'id': '51', 'type': 'pattern_list', 'children': ['52', '53', '54']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'triples'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'tuple', 'children': ['61', '62', '65']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'uriRefFmt'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'RDFS'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'subClassOf'}; {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'if_statement', 'children': ['68', '75']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'formatSubclassOf'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72', '73', '74']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'True', 'children': []}; {'id': '78', 'type': 'for_statement', 'children': ['79', '83', '94']}; {'id': '79', 'type': 'pattern_list', 'children': ['80', '81', '82']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'triples'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'tuple', 'children': ['89', '90', '93']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'uriRefFmt'}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'OWL'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'equivalentClass'}; {'id': '93', 'type': 'None', 'children': []}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'if_statement', 'children': ['96', '103']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'formatSubclassOf'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100', '101', '102']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'True', 'children': []}; {'id': '106', 'type': 'for_statement', 'children': ['107', '111', '122']}; {'id': '107', 'type': 'pattern_list', 'children': ['108', '109', '110']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'triples'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'tuple', 'children': ['117', '118', '121']}; {'id': '117', 'type': 'None', 'children': []}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'OWL'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'equivalentClass'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'uriRefFmt'}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'if_statement', 'children': ['124', '131']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'formatSubclassOf'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128', '129', '130']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'ontology'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'return_statement', 'children': ['133']}; {'id': '133', 'type': 'True', 'children': []}; {'id': '134', 'type': 'return_statement', 'children': ['135']}; {'id': '135', 'type': 'False', 'children': []}
|
Determine if `fmt` is a subclass of `cls`.
|
def paragraph(self, content):
if not self._out.description:
self._out.description = content
return ' '
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'paragraph'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '6', 'type': 'block', 'children': ['7', '23']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_out'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_out'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "' '"}
|
Turn the first paragraph of text into the summary text
|
def version(self):
response = self.get(version="", base="/version")
response.raise_for_status()
data = response.json()
return (data["major"], data["minor"])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'version'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '26', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '16', 'type': 'string', 'children': [], 'value': '""'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"/version"'}; {'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': 'response'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'raise_for_status'}; {'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': 'data'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'tuple', 'children': ['36', '39']}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"major"'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"minor"'}
|
Get Kubernetes API version
|
def _move_here(self):
cu = self.scraper.current_item
if self is cu:
return
if cu.items and self in cu.items:
self.scraper.move_to(self)
return
if self is cu.parent:
self.scraper.move_up()
if self.parent and self in self.parent.items:
self.scraper.move_up()
self.scraper.move_to(self)
return
self.scraper.move_to_top()
for step in self.path:
self.scraper.move_to(step)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_move_here'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '20', '41', '56', '87', '95']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'cu'}; {'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': 'scraper'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'current_item'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': 'is'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cu'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': []}; {'id': '20', 'type': 'if_statement', 'children': ['21', '30']}; {'id': '21', 'type': 'boolean_operator', 'children': ['22', '25'], 'value': 'and'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cu'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'in'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cu'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '30', 'type': 'block', 'children': ['31', '40']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'scraper'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'move_to'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'return_statement', 'children': []}; {'id': '41', 'type': 'if_statement', 'children': ['42', '47']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'is'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'cu'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'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': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'scraper'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'move_up'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'if_statement', 'children': ['57', '68']}; {'id': '57', 'type': 'boolean_operator', 'children': ['58', '61'], 'value': 'and'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '63'], 'value': 'in'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'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': 'parent'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '68', 'type': 'block', 'children': ['69', '77', '86']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '76']}; {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'scraper'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'move_up'}; {'id': '76', 'type': 'argument_list', 'children': []}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '84']}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'scraper'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'move_to'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'return_statement', 'children': []}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '94']}; {'id': '89', 'type': 'attribute', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'scraper'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'move_to_top'}; {'id': '94', 'type': 'argument_list', 'children': []}; {'id': '95', 'type': 'for_statement', 'children': ['96', '97', '100']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '108']}; {'id': '103', 'type': 'attribute', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'scraper'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'move_to'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'step'}
|
Move the cursor to this item.
|
def clear( self ):
item = self.uiActionTREE.currentItem()
if ( not item ):
return
self.uiShortcutTXT.setText('')
item.setText(1, '')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '22', '31']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'uiActionTREE'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'currentItem'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}; {'id': '17', 'type': '()', 'children': ['18']}; {'id': '18', 'type': 'not_operator', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'uiShortcutTXT'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'setText'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "''"}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'setText'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '38', 'type': 'string', 'children': [], 'value': "''"}
|
Clears the current settings for the current action.
|
def OnContentChanged(self, event):
self.main_window.grid.update_attribute_toolbar()
title = self.main_window.GetTitle()
if undo.stack().haschanged():
if title[:2] != "* ":
new_title = "* " + title
post_command_event(self.main_window, self.main_window.TitleMsg,
text=new_title)
elif title[:2] == "* ":
new_title = title[2:]
post_command_event(self.main_window, self.main_window.TitleMsg,
text=new_title)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'OnContentChanged'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '27']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'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': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'main_window'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'grid'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'update_attribute_toolbar'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'title'}; {'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': 'main_window'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'GetTitle'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'if_statement', 'children': ['28', '37', '68']}; {'id': '28', 'type': 'call', 'children': ['29', '36']}; {'id': '29', 'type': 'attribute', 'children': ['30', '35']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'undo'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stack'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'haschanged'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'if_statement', 'children': ['39', '46']}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '45'], 'value': '!='}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '42', 'type': 'slice', 'children': ['43', '44']}; {'id': '43', 'type': 'colon', 'children': []}; {'id': '44', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"* "'}; {'id': '46', 'type': 'block', 'children': ['47', '53']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'new_title'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '+'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"* "'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'post_command_event'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '60', '65']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'main_window'}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'main_window'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'TitleMsg'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'new_title'}; {'id': '68', 'type': 'elif_clause', 'children': ['69', '76']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '75'], 'value': '=='}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '72', 'type': 'slice', 'children': ['73', '74']}; {'id': '73', 'type': 'colon', 'children': []}; {'id': '74', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '75', 'type': 'string', 'children': [], 'value': '"* "'}; {'id': '76', 'type': 'block', 'children': ['77', '85']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'new_title'}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '82', 'type': 'slice', 'children': ['83', '84']}; {'id': '83', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '84', 'type': 'colon', 'children': []}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'post_command_event'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '92', '97']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'main_window'}; {'id': '92', 'type': 'attribute', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'main_window'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'TitleMsg'}; {'id': '97', 'type': 'keyword_argument', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'new_title'}
|
Titlebar star adjustment event handler
|
def _equivalent_node_iterator_helper(self, node: BaseEntity, visited: Set[BaseEntity]) -> BaseEntity:
for v in self[node]:
if v in visited:
continue
if self._has_no_equivalent_edge(node, v):
continue
visited.add(v)
yield v
yield from self._equivalent_node_iterator_helper(v, visited)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_equivalent_node_iterator_helper'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'BaseEntity'}; {'id': '9', 'type': 'typed_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'generic_type', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Set'}; {'id': '14', 'type': 'type_parameter', 'children': ['15']}; {'id': '15', 'type': 'type', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'BaseEntity'}; {'id': '17', 'type': 'type', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'BaseEntity'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '25']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '25', 'type': 'block', 'children': ['26', '32', '42', '49', '52']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'in'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'continue_statement', 'children': []}; {'id': '32', 'type': 'if_statement', 'children': ['33', '40']}; {'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': '_has_no_equivalent_edge'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'continue_statement', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'visited'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'yield', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'yield', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_equivalent_node_iterator_helper'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'visited'}
|
Iterate over nodes and their data that are equal to the given node, starting with the original.
|
async def on_isupport_maxlist(self, value):
self._list_limits = {}
for entry in value.split(','):
modes, limit = entry.split(':')
self._list_limits[frozenset(modes)] = int(limit)
for mode in modes:
self._list_limit_groups[mode] = frozenset(modes)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_isupport_maxlist'}; {'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', '13']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_list_limits'}; {'id': '12', 'type': 'dictionary', 'children': []}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '21']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': "','"}; {'id': '21', 'type': 'block', 'children': ['22', '33', '47']}; {'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': 'modes'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '43']}; {'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': '_list_limits'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'frozenset'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'modes'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '47', 'type': 'for_statement', 'children': ['48', '49', '50']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'modes'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '58']}; {'id': '53', 'type': 'subscript', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_list_limit_groups'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'frozenset'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'modes'}
|
Limits on channel modes involving lists.
|
def _update_simulation_start_cards(self):
if self.simulation_start is not None:
self._update_card("START_DATE", self.simulation_start.strftime("%Y %m %d"))
self._update_card("START_TIME", self.simulation_start.strftime("%H %M"))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_simulation_start_cards'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is not'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'simulation_start'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '28']}; {'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': '_update_card'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"START_DATE"'}; {'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': 'simulation_start'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"%Y %m %d"'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_update_card'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"START_TIME"'}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'simulation_start'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"%H %M"'}
|
Update GSSHA cards for simulation start
|
def reset_state(self):
super(AugmentorList, self).reset_state()
for a in self.augmentors:
a.reset_state()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset_state'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '15']}; {'id': '8', 'type': 'attribute', 'children': ['9', '14']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'AugmentorList'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'reset_state'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '21']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'augmentors'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'reset_state'}; {'id': '27', 'type': 'argument_list', 'children': []}
|
Will reset state of each augmentor
|
def gen_nop():
empty_reg = ReilEmptyOperand()
return ReilBuilder.build(ReilMnemonic.NOP, empty_reg, empty_reg, empty_reg)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_nop'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'empty_reg'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ReilEmptyOperand'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ReilBuilder'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'build'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20', '21', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ReilMnemonic'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'NOP'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'empty_reg'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'empty_reg'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'empty_reg'}
|
Return a NOP instruction.
|
def revert(self, strip=0, root=None):
reverted = copy.deepcopy(self)
reverted._reverse()
return reverted.apply(strip, root)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'revert'}; {'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': 'strip'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '21', '27']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'reverted'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'reverted'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_reverse'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'reverted'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'apply'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'root'}
|
apply patch in reverse order
|
def _urls_for_js(urls=None):
if urls is None:
from .urls import urlpatterns
urls = [url.name for url in urlpatterns if getattr(url, 'name', None)]
urls = dict(zip(urls, [get_uri_template(url) for url in urls]))
urls.update(getattr(settings, 'LEAFLET_STORAGE_EXTRA_URLS', {}))
return urls
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_urls_for_js'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '37', '55', '67']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '20']}; {'id': '13', 'type': 'import_from_statement', 'children': ['14', '18']}; {'id': '14', 'type': 'relative_import', 'children': ['15', '16']}; {'id': '15', 'type': 'import_prefix', 'children': []}; {'id': '16', 'type': 'dotted_name', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '18', 'type': 'dotted_name', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'urlpatterns'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '23', 'type': 'list_comprehension', 'children': ['24', '27', '30']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'for_in_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'urlpatterns'}; {'id': '30', 'type': 'if_clause', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '47', 'type': 'list_comprehension', 'children': ['48', '52']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get_uri_template'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '52', 'type': 'for_in_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'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': 'urls'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65', '66']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'LEAFLET_STORAGE_EXTRA_URLS'"}; {'id': '66', 'type': 'dictionary', 'children': []}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'urls'}
|
Return templated URLs prepared for javascript.
|
async def get_json(self, url, timeout=30, astext=False, exceptions=False):
try:
with async_timeout.timeout(timeout):
res = await self._aio_session.get(url)
if res.status != 200:
_LOGGER.error("QSUSB returned %s [%s]", res.status, url)
return None
res_text = await res.text()
except (aiohttp.client_exceptions.ClientError,
asyncio.TimeoutError) as exc:
if exceptions:
raise exc
return None
if astext:
return res_text
try:
return json.loads(res_text)
except json.decoder.JSONDecodeError:
if res_text.strip(" ") == "":
return None
_LOGGER.error("Could not decode %s [%s]", res_text, url)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '30'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'astext'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '14', 'type': 'False', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16', '90', '95']}; {'id': '16', 'type': 'try_statement', 'children': ['17', '69']}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'with_statement', 'children': ['19', '27']}; {'id': '19', 'type': 'with_clause', 'children': ['20']}; {'id': '20', 'type': 'with_item', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'async_timeout'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '27', 'type': 'block', 'children': ['28', '40', '60']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '31', 'type': 'await', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_aio_session'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '40', 'type': 'if_statement', 'children': ['41', '46']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '45'], 'value': '!='}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '46', 'type': 'block', 'children': ['47', '58']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_LOGGER'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54', '57']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"QSUSB returned %s [%s]"'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'None', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'res_text'}; {'id': '63', 'type': 'await', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'except_clause', 'children': ['70', '82']}; {'id': '70', 'type': 'as_pattern', 'children': ['71', '80']}; {'id': '71', 'type': 'tuple', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'aiohttp'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'client_exceptions'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ClientError'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'TimeoutError'}; {'id': '80', 'type': 'as_pattern_target', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '82', 'type': 'block', 'children': ['83', '88']}; {'id': '83', 'type': 'if_statement', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'raise_statement', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'None', 'children': []}; {'id': '90', 'type': 'if_statement', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'astext'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'res_text'}; {'id': '95', 'type': 'try_statement', 'children': ['96', '104']}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'res_text'}; {'id': '104', 'type': 'except_clause', 'children': ['105', '110']}; {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'decoder'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'JSONDecodeError'}; {'id': '110', 'type': 'block', 'children': ['111', '123']}; {'id': '111', 'type': 'if_statement', 'children': ['112', '120']}; {'id': '112', 'type': 'comparison_operator', 'children': ['113', '119'], 'value': '=='}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'res_text'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '119', 'type': 'string', 'children': [], 'value': '""'}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'return_statement', 'children': ['122']}; {'id': '122', 'type': 'None', 'children': []}; {'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': '_LOGGER'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130', '131']}; {'id': '129', 'type': 'string', 'children': [], 'value': '"Could not decode %s [%s]"'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'res_text'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'url'}
|
Get URL and parse JSON from text.
|
def _get_erred_shared_settings_module(self):
result_module = modules.LinkList(title=_('Shared provider settings in erred state'))
result_module.template = 'admin/dashboard/erred_link_list.html'
erred_state = structure_models.SharedServiceSettings.States.ERRED
queryset = structure_models.SharedServiceSettings.objects
settings_in_erred_state = queryset.filter(state=erred_state).count()
if settings_in_erred_state:
result_module.title = '%s (%s)' % (result_module.title, settings_in_erred_state)
for service_settings in queryset.filter(state=erred_state).iterator():
module_child = self._get_link_to_instance(service_settings)
module_child['error'] = service_settings.error_message
result_module.children.append(module_child)
else:
result_module.pre_content = _('Nothing found.')
return result_module
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_erred_shared_settings_module'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '26', '36', '44', '59', '126']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result_module'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'LinkList'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'Shared provider settings in erred state'"}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'result_module'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'admin/dashboard/erred_link_list.html'"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'erred_state'}; {'id': '29', 'type': 'attribute', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'structure_models'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'SharedServiceSettings'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'States'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ERRED'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'structure_models'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'SharedServiceSettings'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'settings_in_erred_state'}; {'id': '47', 'type': 'call', 'children': ['48', '58']}; {'id': '48', 'type': 'attribute', 'children': ['49', '57']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'erred_state'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'id': '59', 'type': 'if_statement', 'children': ['60', '61', '115']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'settings_in_erred_state'}; {'id': '61', 'type': 'block', 'children': ['62', '74']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'result_module'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '69'], 'value': '%'}; {'id': '68', 'type': 'string', 'children': [], 'value': "'%s (%s)'"}; {'id': '69', 'type': 'tuple', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'result_module'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'settings_in_erred_state'}; {'id': '74', 'type': 'for_statement', 'children': ['75', '76', '88']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'service_settings'}; {'id': '76', 'type': 'call', 'children': ['77', '87']}; {'id': '77', 'type': 'attribute', 'children': ['78', '86']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'erred_state'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'iterator'}; {'id': '87', 'type': 'argument_list', 'children': []}; {'id': '88', 'type': 'block', 'children': ['89', '98', '106']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'module_child'}; {'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_link_to_instance'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'service_settings'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '103']}; {'id': '100', 'type': 'subscript', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'module_child'}; {'id': '102', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'service_settings'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'error_message'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '113']}; {'id': '108', 'type': 'attribute', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'result_module'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'module_child'}; {'id': '115', 'type': 'else_clause', 'children': ['116']}; {'id': '116', 'type': 'block', 'children': ['117']}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'result_module'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'pre_content'}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'string', 'children': [], 'value': "'Nothing found.'"}; {'id': '126', 'type': 'return_statement', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'result_module'}
|
Returns a LinkList based module which contains link to shared service setting instances in ERRED state.
|
def __create_profile_from_identities(self, identities, uuid, verbose):
import re
EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$"
NAME_REGEX = r"^\w+\s\w+"
name = None
email = None
username = None
for identity in identities:
if not name and identity.name:
m = re.match(NAME_REGEX, identity.name)
if m:
name = identity.name
if not email and identity.email:
m = re.match(EMAIL_ADDRESS_REGEX, identity.email)
if m:
email = identity.email
if not username:
if identity.username and identity.username != 'None':
username = identity.username
if not name:
if email:
name = email.split('@')[0]
elif username:
name = username.split('@')[0]
else:
name = None
kw = {'name': name,
'email': email}
api.edit_profile(self.db, uuid, **kw)
self.log("-- profile %s updated" % uuid, verbose)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__create_profile_from_identities'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'identities'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '8', 'type': 'block', 'children': ['9', '12', '16', '20', '24', '28', '32', '115', '153', '163', '175']}; {'id': '9', 'type': 'import_statement', 'children': ['10']}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'EMAIL_ADDRESS_REGEX'}; {'id': '15', 'type': 'string', 'children': [], 'value': 'r"^(?P<email>[^\\s@]+@[^\\s@.]+\\.[^\\s@]+)$"'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'NAME_REGEX'}; {'id': '19', 'type': 'string', 'children': [], 'value': 'r"^\\w+\\s\\w+"'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'identities'}; {'id': '35', 'type': 'block', 'children': ['36', '65', '94']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '43']}; {'id': '37', 'type': 'boolean_operator', 'children': ['38', '40'], 'value': 'and'}; {'id': '38', 'type': 'not_operator', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '43', 'type': 'block', 'children': ['44', '56']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'm'}; {'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': 'match'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'NAME_REGEX'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '65', 'type': 'if_statement', 'children': ['66', '72']}; {'id': '66', 'type': 'boolean_operator', 'children': ['67', '69'], 'value': 'and'}; {'id': '67', 'type': 'not_operator', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '72', 'type': 'block', 'children': ['73', '85']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'EMAIL_ADDRESS_REGEX'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '85', 'type': 'if_statement', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '94', 'type': 'if_statement', 'children': ['95', '97']}; {'id': '95', 'type': 'not_operator', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'if_statement', 'children': ['99', '108']}; {'id': '99', 'type': 'boolean_operator', 'children': ['100', '103'], 'value': 'and'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '107'], 'value': '!='}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '107', 'type': 'string', 'children': [], 'value': "'None'"}; {'id': '108', 'type': 'block', 'children': ['109']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '115', 'type': 'if_statement', 'children': ['116', '118']}; {'id': '116', 'type': 'not_operator', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'if_statement', 'children': ['120', '121', '133', '147']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '125', 'type': 'subscript', 'children': ['126', '132']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}; {'id': '131', 'type': 'string', 'children': [], 'value': "'@'"}; {'id': '132', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '133', 'type': 'elif_clause', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '139', 'type': 'subscript', 'children': ['140', '146']}; {'id': '140', 'type': 'call', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'string', 'children': [], 'value': "'@'"}; {'id': '146', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '147', 'type': 'else_clause', 'children': ['148']}; {'id': '148', 'type': 'block', 'children': ['149']}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '152', 'type': 'None', 'children': []}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '156', 'type': 'dictionary', 'children': ['157', '160']}; {'id': '157', 'type': 'pair', 'children': ['158', '159']}; {'id': '158', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '160', 'type': 'pair', 'children': ['161', '162']}; {'id': '161', 'type': 'string', 'children': [], 'value': "'email'"}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '168']}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'edit_profile'}; {'id': '168', 'type': 'argument_list', 'children': ['169', '172', '173']}; {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '173', 'type': 'dictionary_splat', 'children': ['174']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'call', 'children': ['177', '180']}; {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '180', 'type': 'argument_list', 'children': ['181', '184']}; {'id': '181', 'type': 'binary_operator', 'children': ['182', '183'], 'value': '%'}; {'id': '182', 'type': 'string', 'children': [], 'value': '"-- profile %s updated"'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'uuid'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'verbose'}
|
Create a profile using the data from the identities
|
def simple_prot(x, start):
for i in range(start,len(x)-1):
a,b,c = x[i-1], x[i], x[i+1]
if b - a > 0 and b -c >= 0:
return i
else:
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'simple_prot'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '19', '55']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '18'], 'value': '-'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '19', 'type': 'block', 'children': ['20', '40']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '26']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '26', 'type': 'expression_list', 'children': ['27', '32', '35']}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '-'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '+'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': 'if_statement', 'children': ['41', '52']}; {'id': '41', 'type': 'boolean_operator', 'children': ['42', '47'], 'value': 'and'}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '46'], 'value': '>'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '-'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '51'], 'value': '>='}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '-'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '55', 'type': 'else_clause', 'children': ['56']}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'None', 'children': []}
|
Find the first peak to the right of start
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.