code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def load_rv_data(filename, indep, dep, indweight=None, dir='./'): if '/' in filename: path, filename = os.path.split(filename) else: path = dir load_file = os.path.join(path, filename) rvdata = np.loadtxt(load_file) d ={} d['phoebe_rv_time'] = rvdata[:,0] d['phoebe_rv_vel'] = rvdata[:,1] ncol = len(rvdata[0]) if indweight=="Standard deviation": if ncol >= 3: d['phoebe_rv_sigmarv'] = rvdata[:,2] else: logger.warning('A sigma column is mentioned in the .phoebe file but is not present in the rv data file') elif indweight =="Standard weight": if ncol >= 3: sigma = np.sqrt(1/rvdata[:,2]) d['phoebe_rv_sigmarv'] = sigma logger.warning('Standard weight has been converted to Standard deviation.') else: logger.warning('Phoebe 2 currently only supports standard deviaton') return d
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_rv_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'indep'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dep'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'indweight'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'./'"}; {'id': '13', 'type': 'block', 'children': ['14', '38', '50', '59', '63', '73', '83', '92', '168']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18', '32']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': 'in'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'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': 'path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'load_file'}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'rvdata'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'loadtxt'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'load_file'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '62', 'type': 'dictionary', 'children': []}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'phoebe_rv_time'"}; {'id': '68', 'type': 'subscript', 'children': ['69', '70', '72']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'rvdata'}; {'id': '70', 'type': 'slice', 'children': ['71']}; {'id': '71', 'type': 'colon', 'children': []}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'phoebe_rv_vel'"}; {'id': '78', 'type': 'subscript', 'children': ['79', '80', '82']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'rvdata'}; {'id': '80', 'type': 'slice', 'children': ['81']}; {'id': '81', 'type': 'colon', 'children': []}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ncol'}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'rvdata'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '92', 'type': 'if_statement', 'children': ['93', '96', '121', '159']}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': '=='}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'indweight'}; {'id': '95', 'type': 'string', 'children': [], 'value': '"Standard deviation"'}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'if_statement', 'children': ['98', '101', '112']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': '>='}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'ncol'}; {'id': '100', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'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': 'd'}; {'id': '106', 'type': 'string', 'children': [], 'value': "'phoebe_rv_sigmarv'"}; {'id': '107', 'type': 'subscript', 'children': ['108', '109', '111']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'rvdata'}; {'id': '109', 'type': 'slice', 'children': ['110']}; {'id': '110', 'type': 'colon', 'children': []}; {'id': '111', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '112', 'type': 'else_clause', 'children': ['113']}; {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'string', 'children': [], 'value': "'A sigma column is mentioned in the .phoebe file but is not present in the rv data file'"}; {'id': '121', 'type': 'elif_clause', 'children': ['122', '125']}; {'id': '122', 'type': 'comparison_operator', 'children': ['123', '124'], 'value': '=='}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'indweight'}; {'id': '124', 'type': 'string', 'children': [], 'value': '"Standard weight"'}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'if_statement', 'children': ['127', '130']}; {'id': '127', 'type': 'comparison_operator', 'children': ['128', '129'], 'value': '>='}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'ncol'}; {'id': '129', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '130', 'type': 'block', 'children': ['131', '146', '152']}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'sigma'}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'binary_operator', 'children': ['140', '141'], 'value': '/'}; {'id': '140', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '141', 'type': 'subscript', 'children': ['142', '143', '145']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'rvdata'}; {'id': '143', 'type': 'slice', 'children': ['144']}; {'id': '144', 'type': 'colon', 'children': []}; {'id': '145', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'assignment', 'children': ['148', '151']}; {'id': '148', 'type': 'subscript', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '150', 'type': 'string', 'children': [], 'value': "'phoebe_rv_sigmarv'"}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'sigma'}; {'id': '152', 'type': 'expression_statement', 'children': ['153']}; {'id': '153', 'type': 'call', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'string', 'children': [], 'value': "'Standard weight has been converted to Standard deviation.'"}; {'id': '159', 'type': 'else_clause', 'children': ['160']}; {'id': '160', 'type': 'block', 'children': ['161']}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '166']}; {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}; {'id': '167', 'type': 'string', 'children': [], 'value': "'Phoebe 2 currently only supports standard deviaton'"}; {'id': '168', 'type': 'return_statement', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'd'}
load dictionary with rv data.
def remove_thin_device(name, force=False): cmd = ['dmsetup', 'remove', '--retry', name] r = util.subp(cmd) if not force: if r.return_code != 0: raise MountError('Could not remove thin device:\n%s' % r.stderr.decode(sys.getdefaultencoding()).split("\n")[0])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_thin_device'}; {'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': 'force'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '17', '26']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '12', 'type': 'list', 'children': ['13', '14', '15', '16'], 'value': "['dmsetup', 'remove', '--retry', name]"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'dmsetup'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "'remove'"}; {'id': '15', 'type': 'string', 'children': [], 'value': "'--retry'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'subp'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '29']}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '36']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '35'], 'value': '!='}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'return_code'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'raise_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'MountError'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '%'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'Could not remove thin device:\\n%s'"}; {'id': '43', 'type': 'subscript', 'children': ['44', '61']}; {'id': '44', 'type': 'call', 'children': ['45', '59']}; {'id': '45', 'type': 'attribute', 'children': ['46', '58']}; {'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': 'r'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'getdefaultencoding'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}
Destroys a thin device via subprocess call.
def find_all_by_parameters(self, task_name, session=None, **task_params): with self._session(session) as session: query = session.query(TaskRecord).join(TaskEvent).filter(TaskRecord.name == task_name) for (k, v) in six.iteritems(task_params): alias = sqlalchemy.orm.aliased(TaskParameter) query = query.join(alias).filter(alias.name == k, alias.value == v) tasks = query.order_by(TaskEvent.ts) for task in tasks: assert all(k in task.parameters and v == str(task.parameters[k].value) for (k, v) in six.iteritems(task_params)) yield task
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_all_by_parameters'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'task_name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'dictionary_splat_pattern', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'task_params'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'with_statement', 'children': ['13', '24']}; {'id': '13', 'type': 'with_clause', 'children': ['14']}; {'id': '14', 'type': 'with_item', 'children': ['15']}; {'id': '15', 'type': 'as_pattern', 'children': ['16', '22']}; {'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': '_session'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '22', 'type': 'as_pattern_target', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '24', 'type': 'block', 'children': ['25', '48', '93', '104']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '28', 'type': 'call', 'children': ['29', '42']}; {'id': '29', 'type': 'attribute', 'children': ['30', '41']}; {'id': '30', 'type': 'call', 'children': ['31', '39']}; {'id': '31', 'type': 'attribute', 'children': ['32', '38']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'TaskRecord'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'TaskEvent'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': '=='}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'TaskRecord'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'task_name'}; {'id': '48', 'type': 'for_statement', 'children': ['49', '52', '58']}; {'id': '49', 'type': 'tuple_pattern', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'task_params'}; {'id': '58', 'type': 'block', 'children': ['59', '70']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'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': 'sqlalchemy'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'orm'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'aliased'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'TaskParameter'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '73', 'type': 'call', 'children': ['74', '82']}; {'id': '74', 'type': 'attribute', 'children': ['75', '81']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '88']}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '87'], 'value': '=='}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '92'], 'value': '=='}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'tasks'}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'order_by'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'TaskEvent'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'ts'}; {'id': '104', 'type': 'for_statement', 'children': ['105', '106', '107']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'tasks'}; {'id': '107', 'type': 'block', 'children': ['108', '140']}; {'id': '108', 'type': 'assert_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '111', 'type': 'generator_expression', 'children': ['112', '130']}; {'id': '112', 'type': 'boolean_operator', 'children': ['113', '118'], 'value': 'and'}; {'id': '113', 'type': 'comparison_operator', 'children': ['114', '115'], 'value': 'in'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'parameters'}; {'id': '118', 'type': 'comparison_operator', 'children': ['119', '120'], 'value': '=='}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'attribute', 'children': ['124', '129']}; {'id': '124', 'type': 'subscript', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'parameters'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '130', 'type': 'for_in_clause', 'children': ['131', '134']}; {'id': '131', 'type': 'tuple_pattern', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'task_params'}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}; {'id': '141', 'type': 'yield', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'task'}
Find tasks with the given task_name and the same parameters as the kwargs.
def _ufo_logging_ref(ufo): if ufo.path: return os.path.basename(ufo.path) return ufo.info.styleName
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ufo_logging_ref'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ufo'}; {'id': '5', 'type': 'block', 'children': ['6', '22']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ufo'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ufo'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ufo'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'styleName'}
Return a string that can identify this UFO in logs.
def from_cache(self, section, name): cached_value = self.cache.get( self.get_cache_key(section, name), CachedValueNotFound) if cached_value is CachedValueNotFound: raise CachedValueNotFound if cached_value == preferences_settings.CACHE_NONE_VALUE: cached_value = None return self.registry.get( section=section, name=name).serializer.deserialize(cached_value)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_cache'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'block', 'children': ['8', '26', '33', '44']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cached_value'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '25']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_cache_key'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'CachedValueNotFound'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cached_value'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'CachedValueNotFound'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'raise_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'CachedValueNotFound'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '39']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': '=='}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cached_value'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'preferences_settings'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'CACHE_NONE_VALUE'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cached_value'}; {'id': '43', 'type': 'None', 'children': []}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '63']}; {'id': '46', 'type': 'attribute', 'children': ['47', '62']}; {'id': '47', 'type': 'attribute', 'children': ['48', '61']}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '58']}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'deserialize'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'cached_value'}
Return a preference raw_value from cache
def replace(old, new): parent = old.getparent() parent.replace(old, new)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'replace'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'old'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '6', 'type': 'block', 'children': ['7', '15']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'old'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'getparent'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'old'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'new'}
A simple way to replace one element node with another.
def clear(self): self.sam |= KEY_WRITE for v in list(self.values()): del self[v.name] for k in list(self.subkeys()): self.del_subkey(k.name)
{'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', '12', '29']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'augmented_assignment', 'children': ['8', '11'], 'value': '|='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sam'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'KEY_WRITE'}; {'id': '12', 'type': 'for_statement', 'children': ['13', '14', '22']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'delete_statement', 'children': ['24']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '39']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'subkeys'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'del_subkey'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'name'}
Remove all subkeys and values from this key.
def copychildren(self, newdoc=None, idsuffix=""): if idsuffix is True: idsuffix = ".copy." + "%08x" % random.getrandbits(32) for c in self: if isinstance(c, Word): yield WordReference(newdoc, id=c.id) else: yield c.copy(newdoc,idsuffix)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copychildren'}; {'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': 'newdoc'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'idsuffix'}; {'id': '10', 'type': 'string', 'children': [], 'value': '""'}; {'id': '11', 'type': 'block', 'children': ['12', '30']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '16']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'is'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'idsuffix'}; {'id': '15', 'type': 'True', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'idsuffix'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '+'}; {'id': '21', 'type': 'string', 'children': [], 'value': '".copy."'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '%'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"%08x"'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'getrandbits'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'integer', 'children': [], 'value': '32'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'if_statement', 'children': ['35', '40', '52']}; {'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': 'c'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Word'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'yield', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'WordReference'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'newdoc'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '52', 'type': 'else_clause', 'children': ['53']}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'yield', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'newdoc'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'idsuffix'}
Generator creating a deep copy of the children of this element. If idsuffix is a string, if set to True, a random idsuffix will be generated including a random 32-bit hash
def color(ip, mac, hue, saturation, value): bulb = MyStromBulb(ip, mac) bulb.set_color_hsv(hue, saturation, value)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'color'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mac'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'hue'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'saturation'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '9', 'type': 'block', 'children': ['10', '18']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bulb'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'MyStromBulb'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'mac'}; {'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': 'bulb'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'set_color_hsv'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'hue'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'saturation'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'value'}
Switch the bulb on with the given color.
def create_reader_instances(self, filenames=None, reader=None, reader_kwargs=None): return load_readers(filenames=filenames, reader=reader, reader_kwargs=reader_kwargs, ppp_config_dir=self.ppp_config_dir)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_reader_instances'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'reader_kwargs'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'load_readers'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '22', '25', '28']}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'reader_kwargs'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'reader_kwargs'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ppp_config_dir'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ppp_config_dir'}
Find readers and return their instances.
def __SendMediaBody(self, start, additional_headers=None): self.EnsureInitialized() if self.total_size is None: raise exceptions.TransferInvalidError( 'Total size must be known for SendMediaBody') body_stream = stream_slice.StreamSlice( self.stream, self.total_size - start) request = http_wrapper.Request(url=self.url, http_method='PUT', body=body_stream) request.headers['Content-Type'] = self.mime_type if start == self.total_size: range_string = 'bytes */%s' % self.total_size else: range_string = 'bytes %s-%s/%s' % (start, self.total_size - 1, self.total_size) request.headers['Content-Range'] = range_string if additional_headers: request.headers.update(additional_headers) return self.__SendMediaRequest(request, self.total_size)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__SendMediaBody'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'additional_headers'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '16', '30', '46', '65', '75', '107', '115', '127']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'EnsureInitialized'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '22']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '21'], 'value': 'is'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'total_size'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'raise_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'TransferInvalidError'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'Total size must be known for SendMediaBody'"}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'body_stream'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'stream_slice'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'StreamSlice'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '45'], 'value': '-'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'total_size'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'http_wrapper'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'Request'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '59', '62']}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'http_method'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'PUT'"}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'body_stream'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '72']}; {'id': '67', 'type': 'subscript', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'Content-Type'"}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'mime_type'}; {'id': '75', 'type': 'if_statement', 'children': ['76', '81', '90']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '78'], 'value': '=='}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'total_size'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'range_string'}; {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '%'}; {'id': '86', 'type': 'string', 'children': [], 'value': "'bytes */%s'"}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'total_size'}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'range_string'}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '97'], 'value': '%'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'bytes %s-%s/%s'"}; {'id': '97', 'type': 'tuple', 'children': ['98', '99', '104']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '103'], 'value': '-'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'total_size'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'total_size'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '114']}; {'id': '109', 'type': 'subscript', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '113', 'type': 'string', 'children': [], 'value': "'Content-Range'"}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'range_string'}; {'id': '115', 'type': 'if_statement', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'additional_headers'}; {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '125']}; {'id': '120', 'type': 'attribute', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'additional_headers'}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'call', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': '__SendMediaRequest'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'total_size'}
Send the entire media stream in a single request.
def insertDict(self, tblname, d, fields = None): if fields == None: fields = sorted(d.keys()) values = None try: SQL = 'INSERT INTO %s (%s) VALUES (%s)' % (tblname, join(fields, ", "), join(['%s' for x in range(len(fields))], ',')) values = tuple([d[k] for k in fields]) self.locked_execute(SQL, parameters = values) except Exception, e: if SQL and values: sys.stderr.write("\nSQL execution error in query '%s' %% %s at %s:" % (SQL, values, datetime.now().strftime("%Y-%m-%d %H:%M:%S"))) sys.stderr.write("\nError: '%s'.\n" % (str(e))) sys.stderr.flush() raise Exception("Error occurred during database insertion: '%s'." % str(e))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'insertDict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tblname'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '27', '31']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': '=='}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'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': 'fields'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'try_statement', 'children': ['32', '83']}; {'id': '32', 'type': 'block', 'children': ['33', '60', '73']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'SQL'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '%'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'INSERT INTO %s (%s) VALUES (%s)'"}; {'id': '38', 'type': 'tuple', 'children': ['39', '40', '45']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'tblname'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '44', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '59']}; {'id': '48', 'type': 'list_comprehension', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'%s'"}; {'id': '50', 'type': 'for_in_clause', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '59', 'type': 'string', 'children': [], 'value': "','"}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'list_comprehension', 'children': ['67', '70']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '70', 'type': 'for_in_clause', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'locked_execute'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'SQL'}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'parameters'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '83', 'type': 'except_clause', 'children': ['84', '85', '86']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '86', 'type': 'block', 'children': ['87', '115', '130', '138']}; {'id': '87', 'type': 'if_statement', 'children': ['88', '91']}; {'id': '88', 'type': 'boolean_operator', 'children': ['89', '90'], 'value': 'and'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'SQL'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '99']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '%'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"\\nSQL execution error in query \'%s\' %% %s at %s:"'}; {'id': '102', 'type': 'tuple', 'children': ['103', '104', '105']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'SQL'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '105', 'type': 'call', 'children': ['106', '113']}; {'id': '106', 'type': 'attribute', 'children': ['107', '112']}; {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '111', 'type': 'argument_list', 'children': []}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'string', 'children': [], 'value': '"%Y-%m-%d %H:%M:%S"'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '122']}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '125'], 'value': '%'}; {'id': '124', 'type': 'string', 'children': [], 'value': '"\\nError: \'%s\'.\\n"'}; {'id': '125', 'type': '()', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'call', 'children': ['132', '137']}; {'id': '132', 'type': 'attribute', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '137', 'type': 'argument_list', 'children': []}; {'id': '138', 'type': 'raise_statement', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'binary_operator', 'children': ['143', '144'], 'value': '%'}; {'id': '143', 'type': 'string', 'children': [], 'value': '"Error occurred during database insertion: \'%s\'."'}; {'id': '144', 'type': 'call', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'e'}
Simple function for inserting a dictionary whose keys match the fieldnames of tblname.
def decode_from_sha(sha): if isinstance(sha, str): sha = sha.encode('utf-8') return codecs.decode(re.sub(rb'(00)*$', b'', sha), "hex_codec")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'decode_from_sha'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sha'}; {'id': '5', 'type': 'block', 'children': ['6', '22']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'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': 'sha'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sha'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sha'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'codecs'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '36']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'string', 'children': [], 'value': "rb'(00)*$'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "b''"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sha'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"hex_codec"'}
convert coerced sha back into numeric list
def partition(self, ref=None, **kwargs): from ambry.orm.exc import NotFoundError from sqlalchemy.orm.exc import NoResultFound if not ref and not kwargs: return None if ref: for p in self.partitions: if ref == p.name or ref == p.vname or ref == p.vid or ref == p.id: p._bundle = self return p raise NotFoundError("No partition found for '{}' (a)".format(ref)) elif kwargs: from ..identity import PartitionNameQuery pnq = PartitionNameQuery(**kwargs) try: p = self.partitions._find_orm(pnq).one() if p: p._bundle = self return p except NoResultFound: raise NotFoundError("No partition found for '{}' (b)".format(kwargs))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'partition'}; {'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': 'ref'}; {'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', '18', '25', '34']}; {'id': '11', 'type': 'import_from_statement', 'children': ['12', '16']}; {'id': '12', 'type': 'dotted_name', 'children': ['13', '14', '15']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ambry'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'orm'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '16', 'type': 'dotted_name', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'NotFoundError'}; {'id': '18', 'type': 'import_from_statement', 'children': ['19', '23']}; {'id': '19', 'type': 'dotted_name', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sqlalchemy'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'orm'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '23', 'type': 'dotted_name', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'NoResultFound'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '31']}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '29'], 'value': 'and'}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '29', 'type': 'not_operator', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '36', '86']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '36', 'type': 'block', 'children': ['37', '76']}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '42']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'partitions'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '67']}; {'id': '44', 'type': 'boolean_operator', 'children': ['45', '62'], 'value': 'or'}; {'id': '45', 'type': 'boolean_operator', 'children': ['46', '57'], 'value': 'or'}; {'id': '46', 'type': 'boolean_operator', 'children': ['47', '52'], 'value': 'or'}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': '=='}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': '=='}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'vname'}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '59'], 'value': '=='}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'vid'}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': '=='}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '67', 'type': 'block', 'children': ['68', '74']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_bundle'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '76', 'type': 'raise_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'NotFoundError'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': '"No partition found for \'{}\' (a)"'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '86', 'type': 'elif_clause', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '88', 'type': 'block', 'children': ['89', '96', '104']}; {'id': '89', 'type': 'import_from_statement', 'children': ['90', '94']}; {'id': '90', 'type': 'relative_import', 'children': ['91', '92']}; {'id': '91', 'type': 'import_prefix', 'children': []}; {'id': '92', 'type': 'dotted_name', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '94', 'type': 'dotted_name', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'PartitionNameQuery'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'pnq'}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'PartitionNameQuery'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'dictionary_splat', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '104', 'type': 'try_statement', 'children': ['105', '132']}; {'id': '105', 'type': 'block', 'children': ['106', '121']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '109', 'type': 'call', 'children': ['110', '120']}; {'id': '110', 'type': 'attribute', 'children': ['111', '119']}; {'id': '111', 'type': 'call', 'children': ['112', '117']}; {'id': '112', 'type': 'attribute', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'partitions'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': '_find_orm'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'pnq'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'one'}; {'id': '120', 'type': 'argument_list', 'children': []}; {'id': '121', 'type': 'if_statement', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '123', 'type': 'block', 'children': ['124', '130']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': '_bundle'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '132', 'type': 'except_clause', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'NoResultFound'}; {'id': '134', 'type': 'block', 'children': ['135']}; {'id': '135', 'type': 'raise_statement', 'children': ['136']}; {'id': '136', 'type': 'call', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'NotFoundError'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'string', 'children': [], 'value': '"No partition found for \'{}\' (b)"'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Return a partition in this bundle for a vid reference or name parts
def register(self, name, obj): if name in self.all: log.debug('register: %s already existed: %s', name, obj.name) raise DuplicateDefinitionException( 'register: %s already existed: %s' % (name, obj.name)) log.debug('register: %s ', name) self.all[name] = obj return obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '7', 'type': 'block', 'children': ['8', '37', '45', '53']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '14', 'type': 'block', 'children': ['15', '26']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'register: %s already existed: %s'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'DuplicateDefinitionException'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '32'], 'value': '%'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'register: %s already existed: %s'"}; {'id': '32', 'type': 'tuple', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'register: %s '"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '52']}; {'id': '47', 'type': 'subscript', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'obj'}
Registers an unique type description
def walk_revctrl(dirname='', ff=''): file_finder = None items = [] if not ff: distutils.log.error('No file-finder passed to walk_revctrl') sys.exit(1) for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): if ff == ep.name: distutils.log.info('using %s file-finder', ep.name) file_finder = ep.load() finder_items = [] with pythonpath_off(): for item in file_finder(dirname): if not basename(item).startswith(('.svn', '.hg', '.git')): finder_items.append(item) distutils.log.info('%d files found', len(finder_items)) items.extend(finder_items) if file_finder is None: distutils.log.error('Failed to load %s file-finder; setuptools-%s extension missing?', ff, 'subversion' if ff == 'svn' else ff) sys.exit(1) return items or ['']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'walk_revctrl'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '6', 'type': 'string', 'children': [], 'value': "''"}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '9', 'type': 'string', 'children': [], 'value': "''"}; {'id': '10', 'type': 'block', 'children': ['11', '15', '19', '39', '135', '163']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'file_finder'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '22']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '22', 'type': 'block', 'children': ['23', '32']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'distutils'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'No file-finder passed to walk_revctrl'"}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '47']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'iter_entry_points'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'setuptools.file_finders'"}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'if_statement', 'children': ['49', '54']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': '=='}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '54', 'type': 'block', 'children': ['55', '67', '75', '79', '115', '128']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'distutils'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'using %s file-finder'"}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'file_finder'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'ep'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'finder_items'}; {'id': '78', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '79', 'type': 'with_statement', 'children': ['80', '85']}; {'id': '80', 'type': 'with_clause', 'children': ['81']}; {'id': '81', 'type': 'with_item', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'pythonpath_off'}; {'id': '84', 'type': 'argument_list', 'children': []}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'for_statement', 'children': ['87', '88', '92']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'file_finder'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'if_statement', 'children': ['94', '107']}; {'id': '94', 'type': 'not_operator', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '102']}; {'id': '96', 'type': 'attribute', 'children': ['97', '101']}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'tuple', 'children': ['104', '105', '106']}; {'id': '104', 'type': 'string', 'children': [], 'value': "'.svn'"}; {'id': '105', 'type': 'string', 'children': [], 'value': "'.hg'"}; {'id': '106', 'type': 'string', 'children': [], 'value': "'.git'"}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'finder_items'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '122']}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'distutils'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}; {'id': '123', 'type': 'string', 'children': [], 'value': "'%d files found'"}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'finder_items'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'finder_items'}; {'id': '135', 'type': 'if_statement', 'children': ['136', '139']}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '138'], 'value': 'is'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'file_finder'}; {'id': '138', 'type': 'None', 'children': []}; {'id': '139', 'type': 'block', 'children': ['140', '156']}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '147']}; {'id': '142', 'type': 'attribute', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'distutils'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '147', 'type': 'argument_list', 'children': ['148', '149', '150']}; {'id': '148', 'type': 'string', 'children': [], 'value': "'Failed to load %s file-finder; setuptools-%s extension missing?'"}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '150', 'type': 'conditional_expression', 'children': ['151', '152', '155'], 'value': 'if'}; {'id': '151', 'type': 'string', 'children': [], 'value': "'subversion'"}; {'id': '152', 'type': 'comparison_operator', 'children': ['153', '154'], 'value': '=='}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '154', 'type': 'string', 'children': [], 'value': "'svn'"}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'ff'}; {'id': '156', 'type': 'expression_statement', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '163', 'type': 'return_statement', 'children': ['164']}; {'id': '164', 'type': 'boolean_operator', 'children': ['165', '166'], 'value': 'or'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '166', 'type': 'list', 'children': ['167'], 'value': "['']"}; {'id': '167', 'type': 'string', 'children': [], 'value': "''"}
Return files found by the file-finder 'ff'.
def upload_celery_conf(command='celeryd', app_name=None, template_name=None, context=None): app_name = app_name or command default = {'app_name': app_name, 'command': command} context = context or {} default.update(context) template_name = template_name or [u'supervisor/%s.conf' % command, u'supervisor/celery.conf'] upload_supervisor_app_conf(app_name=app_name, template_name=template_name, context=default)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload_celery_conf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '6', 'type': 'string', 'children': [], 'value': "'celeryd'"}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'template_name'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '23', '33', '39', '46', '56']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '22'], 'value': 'or'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '26', 'type': 'dictionary', 'children': ['27', '30']}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'app_name'"}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'command'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '36', 'type': 'boolean_operator', 'children': ['37', '38'], 'value': 'or'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '38', 'type': 'dictionary', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'template_name'}; {'id': '49', 'type': 'boolean_operator', 'children': ['50', '51'], 'value': 'or'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'template_name'}; {'id': '51', 'type': 'list', 'children': ['52', '55'], 'value': "[u'supervisor/%s.conf' % command, u'supervisor/celery.conf']"}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '%'}; {'id': '53', 'type': 'string', 'children': [], 'value': "u'supervisor/%s.conf'"}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '55', 'type': 'string', 'children': [], 'value': "u'supervisor/celery.conf'"}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'upload_supervisor_app_conf'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63', '66']}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'template_name'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'template_name'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'default'}
Upload Supervisor configuration for a celery command.
def update_identity(self): fr = self.record d = fr.unpacked_contents d['identity'] = self._dataset.identity.ident_dict d['names'] = self._dataset.identity.names_dict fr.update_contents(msgpack.packb(d), 'application/msgpack')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_identity'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '30', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'fr'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'fr'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'unpacked_contents'}; {'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': 'd'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'identity'"}; {'id': '23', 'type': 'attribute', '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': '_dataset'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ident_dict'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'names'"}; {'id': '35', 'type': 'attribute', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_dataset'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'names_dict'}; {'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': 'fr'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'update_contents'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '54']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'msgpack'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'packb'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'application/msgpack'"}
Update the identity and names to match the dataset id and version
def write(self, fptr): self._validate(writing=True) num_items = len(self.fragment_offset) length = 8 + 2 + num_items * 14 fptr.write(struct.pack('>I4s', length, b'flst')) fptr.write(struct.pack('>H', num_items)) for j in range(num_items): write_buffer = struct.pack('>QIH', self.fragment_offset[j], self.fragment_length[j], self.data_reference[j]) fptr.write(write_buffer)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fptr'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '35', '49', '62']}; {'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': ['13']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'writing'}; {'id': '15', 'type': 'True', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'num_items'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'len'}; {'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': 'fragment_offset'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '32'], 'value': '+'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '+'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '*'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'num_items'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '14'}; {'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': 'fptr'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '48']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'>I4s'"}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '48', 'type': 'string', 'children': [], 'value': "b'flst'"}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'fptr'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'>H'"}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'num_items'}; {'id': '62', 'type': 'for_statement', 'children': ['63', '64', '68']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'num_items'}; {'id': '68', 'type': 'block', 'children': ['69', '93']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'write_buffer'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78', '83', '88']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'>QIH'"}; {'id': '78', 'type': 'subscript', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'fragment_offset'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '83', 'type': 'subscript', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'fragment_length'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '88', 'type': 'subscript', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'data_reference'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'j'}; {'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': 'fptr'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'write_buffer'}
Write a fragment list box to file.
def create(self, key, value=None, dir=False, ttl=None, timeout=None): return self.adapter.set(key, value, dir=dir, ttl=ttl, prev_exist=False, timeout=timeout)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ttl'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28', '29', '32', '35', '38']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ttl'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ttl'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'prev_exist'}; {'id': '37', 'type': 'False', 'children': []}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'timeout'}
Creates a new key.
def init(*args, **kwargs): default_log_level = kwargs.pop("default_log_level", None) import cellpy.log as log log.setup_logging(custom_log_dir=prms.Paths["filelogdir"], default_level=default_log_level) b = Batch(*args, **kwargs) return b
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '19', '25', '41', '51']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'default_log_level'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"default_log_level"'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'import_statement', 'children': ['20']}; {'id': '20', 'type': 'aliased_import', 'children': ['21', '24']}; {'id': '21', 'type': 'dotted_name', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cellpy'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'log'}; {'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': 'log'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'setup_logging'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '38']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'custom_log_dir'}; {'id': '33', 'type': 'subscript', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'prms'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Paths'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"filelogdir"'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'default_level'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'default_log_level'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Batch'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '49']}; {'id': '47', 'type': 'list_splat', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '49', 'type': 'dictionary_splat', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'b'}
Returns an initialized instance of the Batch class
def _stop_timers(canvas): for attr in dir(canvas): try: attr_obj = getattr(canvas, attr) except NotImplementedError: attr_obj = None if isinstance(attr_obj, Timer): attr_obj.stop()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_stop_timers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'canvas'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '12']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'canvas'}; {'id': '12', 'type': 'block', 'children': ['13', '30']}; {'id': '13', 'type': 'try_statement', 'children': ['14', '23']}; {'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': 'attr_obj'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'canvas'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '23', 'type': 'except_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'NotImplementedError'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'attr_obj'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'if_statement', 'children': ['31', '36']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'attr_obj'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Timer'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'attr_obj'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '42', 'type': 'argument_list', 'children': []}
Stop all timers in a canvas.
def drop(self): if self._is_dropped is False: self.table.drop(self.engine) self._is_dropped = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'drop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_is_dropped'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'drop'}; {'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': 'engine'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_is_dropped'}; {'id': '29', 'type': 'True', 'children': []}
Drop the table from the database
def extract_element(self, vector, idx, name=''): instr = instructions.ExtractElement(self.block, vector, idx, name=name) self._insert(instr) return instr
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_element'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '9', 'type': 'string', 'children': [], 'value': "''"}; {'id': '10', 'type': 'block', 'children': ['11', '27', '34']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'instr'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'instructions'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ExtractElement'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '22', '23', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'block'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'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': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_insert'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'instr'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'instr'}
Returns the value at position idx.
def split_title(title, width, title_fs): titles = [] if not title: return titles size = reverse_text_len(width, title_fs * 1.1) title_lines = title.split("\n") for title_line in title_lines: while len(title_line) > size: title_part = title_line[:size] i = title_part.rfind(' ') if i == -1: i = len(title_part) titles.append(title_part[:i]) title_line = title_line[i:].strip() titles.append(title_line) return titles
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_title'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'title_fs'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '18', '28', '37', '109']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'titles'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '15']}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'titles'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'reverse_text_len'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '*'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'title_fs'}; {'id': '27', 'type': 'float', 'children': [], 'value': '1.1'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'title_lines'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'title_line'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'title_lines'}; {'id': '40', 'type': 'block', 'children': ['41', '102']}; {'id': '41', 'type': 'while_statement', 'children': ['42', '48']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '47'], 'value': '>'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'title_line'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '48', 'type': 'block', 'children': ['49', '57', '66', '79', '90']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'title_part'}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'title_line'}; {'id': '54', 'type': 'slice', 'children': ['55', '56']}; {'id': '55', 'type': 'colon', 'children': []}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'title_part'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'rfind'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '66', 'type': 'if_statement', 'children': ['67', '71']}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': '=='}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '69', 'type': 'unary_operator', 'children': ['70'], 'value': '-'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'title_part'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'titles'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'title_part'}; {'id': '87', 'type': 'slice', 'children': ['88', '89']}; {'id': '88', 'type': 'colon', 'children': []}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'title_line'}; {'id': '93', 'type': 'call', 'children': ['94', '101']}; {'id': '94', 'type': 'attribute', 'children': ['95', '100']}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'title_line'}; {'id': '97', 'type': 'slice', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '99', 'type': 'colon', 'children': []}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'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': 'titles'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'title_line'}; {'id': '109', 'type': 'return_statement', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'titles'}
Split a string for a specified width and font size
def cast_number_strings_to_integers(d): for k, v in d.items(): if determine_if_str_or_unicode(v): if v.isdigit(): d[k] = int(v) return d
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cast_number_strings_to_integers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '5', 'type': 'block', 'children': ['6', '38']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '15']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '21']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'determine_if_str_or_unicode'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '28']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'isdigit'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'd'}
d is a dict
def indim(self): indim = self.numOffbids * len(self.generators) if self.maxWithhold is not None: return indim * 2 else: return indim
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'indim'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'indim'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '13'], 'value': '*'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'numOffbids'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'generators'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '25', '30']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '24'], 'value': 'is not'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'maxWithhold'}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '*'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'indim'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '30', 'type': 'else_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'indim'}
The number of action values that the environment accepts.
def subscribe(self, topic=b''): self.sockets[zmq.SUB].setsockopt(zmq.SUBSCRIBE, topic) poller = self.pollers[zmq.SUB] return poller
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'subscribe'}; {'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': 'topic'}; {'id': '7', 'type': 'string', 'children': [], 'value': "b''"}; {'id': '8', 'type': 'block', 'children': ['9', '25', '35']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '20']}; {'id': '11', 'type': 'attribute', 'children': ['12', '19']}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sockets'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'zmq'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'SUB'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'setsockopt'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'zmq'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'SUBSCRIBE'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'topic'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'poller'}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pollers'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'zmq'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'SUB'}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'poller'}
subscribe to the SUB socket, to listen for incomming variables, return a stream that can be listened to.
def retrieve_data(self): df = self.manager.get_historic_data(self.start.date(), self.end.date()) df.replace(0, np.nan, inplace=True) return df
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retrieve_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '30', '43']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'df'}; {'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': 'manager'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_historic_data'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '23']}; {'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': 'start'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'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': 'end'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'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': 'df'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37', '40']}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'inplace'}; {'id': '42', 'type': 'True', 'children': []}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'df'}
Retrives data as a DataFrame.
def PARAMLIMITS(self, value): assert set(value.keys()) == set(self.PARAMLIMITS.keys()), "The \ new parameter limits are not defined for the same set \ of parameters as before." for param in value.keys(): assert value[param][0] < value[param][1], "The new \ minimum value for {0}, {1}, is equal to or \ larger than the new maximum value, {2}"\ .format(param, value[param][0], value[param][1]) self._PARAMLIMITS = value.copy()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'PARAMLIMITS'}; {'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', '28', '65']}; {'id': '7', 'type': 'assert_statement', 'children': ['8', '27']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '17'], 'value': '=='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'set'}; {'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': 'PARAMLIMITS'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'string', 'children': [], 'value': '"The \\\n new parameter limits are not defined for the same set \\\n of parameters as before."'}; {'id': '28', 'type': 'for_statement', 'children': ['29', '30', '35']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'assert_statement', 'children': ['37', '48']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '43'], 'value': '<'}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'subscript', 'children': ['44', '47']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'call', 'children': ['49', '53']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51', '52']}; {'id': '50', 'type': 'string', 'children': [], 'value': '"The new \\\n minimum value for {0}, {1}, is equal to or \\\n larger than the new maximum value, {2}"'}; {'id': '51', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '60']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '55', 'type': 'subscript', 'children': ['56', '59']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'subscript', 'children': ['61', '64']}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_PARAMLIMITS'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '74', 'type': 'argument_list', 'children': []}
Set new `PARAMLIMITS` dictionary.
def build_target_areas(entry): target_areas = [] areas = str(entry['cap:areaDesc']).split(';') for area in areas: target_areas.append(area.strip()) return target_areas
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_target_areas'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '24', '39']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'target_areas'}; {'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': 'areas'}; {'id': '13', 'type': 'call', 'children': ['14', '22']}; {'id': '14', 'type': 'attribute', 'children': ['15', '21']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'cap:areaDesc'"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': "';'"}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '27']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'area'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'areas'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'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': 'target_areas'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'area'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'target_areas'}
Cleanup the raw target areas description string
async def volume(self, ctx, volume: int): if ctx.voice_client is None: return await ctx.send("Not connected to a voice channel.") ctx.voice_client.source.volume = volume / 100 await ctx.send("Changed volume to {}%".format(volume))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'volume'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '6', 'type': 'typed_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '10', 'type': 'block', 'children': ['11', '26', '38']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '17']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '16'], 'value': 'is'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'voice_client'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'await', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"Not connected to a voice channel."'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '35']}; {'id': '28', 'type': 'attribute', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'voice_client'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '/'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'await', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"Changed volume to {}%"'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'volume'}
Changes the player's volume
def select_models(clas,pool_or_cursor,**kwargs): "returns generator yielding instances of the class" if 'columns' in kwargs: raise ValueError("don't pass 'columns' to select_models") return (set_options(pool_or_cursor,clas(*row)) for row in clas.select(pool_or_cursor,**kwargs))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_models'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'clas'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pool_or_cursor'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '11', '21']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"returns generator yielding instances of the class"'}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'columns'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'raise_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"don\'t pass \'columns\' to select_models"'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'generator_expression', 'children': ['23', '32']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'set_options'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pool_or_cursor'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'clas'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'list_splat', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '32', 'type': 'for_in_clause', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'clas'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'pool_or_cursor'}; {'id': '40', 'type': 'dictionary_splat', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
returns generator yielding instances of the class
def schema(ctx, schema): data = yaml.load(schema) if not isinstance(data, (list, tuple)): data = [data] with click.progressbar(data, label=schema.name) as bar: for schema in bar: ctx.obj['grano'].schemata.upsert(schema)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schema'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '31']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '25']}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'tuple', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '29', 'type': 'list', 'children': ['30'], 'value': '[data]'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'with_statement', 'children': ['32', '48']}; {'id': '32', 'type': 'with_clause', 'children': ['33']}; {'id': '33', 'type': 'with_item', 'children': ['34']}; {'id': '34', 'type': 'as_pattern', 'children': ['35', '46']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'progressbar'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '46', 'type': 'as_pattern_target', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'bar'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '52']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'bar'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '64']}; {'id': '55', 'type': 'attribute', 'children': ['56', '63']}; {'id': '56', 'type': 'attribute', 'children': ['57', '62']}; {'id': '57', 'type': 'subscript', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'grano'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'schemata'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'upsert'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'schema'}
Load schema definitions from a YAML file.
async def get_property(self, command): _LOGGER.debug("Getting property %s", command) if self.__checkLock(): return BUSY timeout = self.__get_timeout(command) response = await self.send_request( timeout=timeout, params=EPSON_KEY_COMMANDS[command], type='json_query') if not response: return False try: return response['projector']['feature']['reply'] except KeyError: return BUSY
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_property'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '24', '33', '53', '59']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_LOGGER'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"Getting property %s"'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '21']}; {'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': '__checkLock'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'BUSY'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '__get_timeout'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '36', 'type': 'await', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'send_request'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '45', '50']}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'EPSON_KEY_COMMANDS'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'json_query'"}; {'id': '53', 'type': 'if_statement', 'children': ['54', '56']}; {'id': '54', 'type': 'not_operator', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'False', 'children': []}; {'id': '59', 'type': 'try_statement', 'children': ['60', '69']}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'subscript', 'children': ['63', '68']}; {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'subscript', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '66', 'type': 'string', 'children': [], 'value': "'projector'"}; {'id': '67', 'type': 'string', 'children': [], 'value': "'feature'"}; {'id': '68', 'type': 'string', 'children': [], 'value': "'reply'"}; {'id': '69', 'type': 'except_clause', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'BUSY'}
Get property state from device.
def diff(self, obj=None): if self.no_resource: return NOOP if not self.present: if self.existing: return DEL return NOOP if not obj: obj = self.obj() is_diff = NOOP if self.present and self.existing: if isinstance(self.existing, dict): current = dict(self.existing) if 'refresh_interval' in current: del current['refresh_interval'] if diff_dict(current, obj): is_diff = CHANGED elif is_unicode(self.existing): if self.existing != obj: is_diff = CHANGED elif self.present and not self.existing: is_diff = ADD return is_diff
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diff'}; {'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': 'obj'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '16', '31', '43', '47', '127']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'no_resource'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'NOOP'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '21']}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'present'}; {'id': '21', 'type': 'block', 'children': ['22', '29']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'existing'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'DEL'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'NOOP'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '34']}; {'id': '32', 'type': 'not_operator', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'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': 'obj'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'is_diff'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'NOOP'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '55', '113']}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '52'], 'value': 'and'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'present'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'existing'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'if_statement', 'children': ['57', '64', '94']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'existing'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '64', 'type': 'block', 'children': ['65', '74', '83']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'existing'}; {'id': '74', 'type': 'if_statement', 'children': ['75', '78']}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '77'], 'value': 'in'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'refresh_interval'"}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'delete_statement', 'children': ['80']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'refresh_interval'"}; {'id': '83', 'type': 'if_statement', 'children': ['84', '89']}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'diff_dict'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'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': 'is_diff'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'CHANGED'}; {'id': '94', 'type': 'elif_clause', 'children': ['95', '101']}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'is_unicode'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'existing'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'if_statement', 'children': ['103', '108']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '107'], 'value': '!='}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'existing'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'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': 'is_diff'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'CHANGED'}; {'id': '113', 'type': 'elif_clause', 'children': ['114', '122']}; {'id': '114', 'type': 'boolean_operator', 'children': ['115', '118'], 'value': 'and'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'present'}; {'id': '118', 'type': 'not_operator', 'children': ['119']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'existing'}; {'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': 'is_diff'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'ADD'}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'is_diff'}
Determine if something has changed or not
def peers_by_group(self, name): return czmq.Zlist(lib.zyre_peers_by_group(self._as_parameter_, name), True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'peers_by_group'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'czmq'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Zlist'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '22']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'lib'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'zyre_peers_by_group'}; {'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': '_as_parameter_'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'True', 'children': []}
Return zlist of current peers of this group.
async def controller(self): return await Connection.connect( self.endpoint, username=self.username, password=self.password, cacert=self.cacert, bakery_client=self.bakery_client, loop=self.loop, max_frame_size=self.max_frame_size, )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'controller'}; {'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': 'await', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Connection'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16', '21', '26', '31', '36', '41']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cacert'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cacert'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'bakery_client'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'bakery_client'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'max_frame_size'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'max_frame_size'}
Return a Connection to the controller at self.endpoint
def qmark(cls, query): def sub_sequence(m): s = m.group(0) if s == "??": return "?" if s == "%": return "%%" else: return "%s" return cls.RE_QMARK.sub(sub_sequence, query)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qmark'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '6', 'type': 'block', 'children': ['7', '39']}; {'id': '7', 'type': 'function_definition', 'children': ['8', '9', '11']}; {'id': '8', 'type': 'function_name', 'children': [], 'value': 'sub_sequence'}; {'id': '9', 'type': 'parameters', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '11', 'type': 'block', 'children': ['12', '21', '28']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '25']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': '=='}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"??"'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"?"'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32', '35']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"%"'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"%%"'}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"%s"'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'RE_QMARK'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sub_sequence'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'query'}
Convert a "qmark" query into "format" style.
def returner(ret): opts = _get_options(ret) try: with salt.utils.files.flopen(opts['filename'], 'a') as logfile: salt.utils.json.dump(ret, logfile) logfile.write(str('\n')) except Exception: log.error('Could not write to rawdata_json file %s', opts['filename']) raise
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'returner'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '5', 'type': 'block', 'children': ['6', '13']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_get_options'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '13', 'type': 'try_statement', 'children': ['14', '57']}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'with_statement', 'children': ['16', '34']}; {'id': '16', 'type': 'with_clause', 'children': ['17']}; {'id': '17', 'type': 'with_item', 'children': ['18']}; {'id': '18', 'type': 'as_pattern', 'children': ['19', '32']}; {'id': '19', 'type': 'call', 'children': ['20', '27']}; {'id': '20', 'type': 'attribute', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'flopen'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'filename'"}; {'id': '31', 'type': 'string', 'children': [], 'value': "'a'"}; {'id': '32', 'type': 'as_pattern_target', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '34', 'type': 'block', 'children': ['35', '47']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '44']}; {'id': '37', 'type': 'attribute', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'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': 'logfile'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '57', 'type': 'except_clause', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '59', 'type': 'block', 'children': ['60', '70']}; {'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': 'log'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'Could not write to rawdata_json file %s'"}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'filename'"}; {'id': '70', 'type': 'raise_statement', 'children': []}
Write the return data to a file on the minion.
def file_fingerprint(fullpath): stat = os.stat(fullpath) return ','.join([str(value) for value in [stat.st_ino, stat.st_mtime, stat.st_size] if value])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'file_fingerprint'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fullpath'}; {'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': 'stat'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fullpath'}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "','"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '26', '38']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '28', 'type': 'list', 'children': ['29', '32', '35'], 'value': '[stat.st_ino, stat.st_mtime, stat.st_size]'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'st_ino'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'st_mtime'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'st_size'}; {'id': '38', 'type': 'if_clause', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'value'}
Get a metadata fingerprint for a file
def import_mock(name, *args, **kwargs): if any(name.startswith(s) for s in mock_modules): return MockModule() return orig_import(name, *args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_mock'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '28']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '23']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '13', 'type': 'generator_expression', 'children': ['14', '20']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'mock_modules'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'MockModule'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'orig_import'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '35']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'list_splat', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '35', 'type': 'dictionary_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Mock all modules starting with one of the mock_modules names.
def _is_valid_decimal(self, inpt, metadata): if not (isinstance(inpt, float) or isinstance(inpt, Decimal)): return False if not isinstance(inpt, Decimal): inpt = Decimal(str(inpt)) if metadata.get_minimum_decimal() and inpt < metadata.get_minimum_decimal(): return False if metadata.get_maximum_decimal() and inpt > metadata.get_maximum_decimal(): return False if metadata.get_decimal_set() and inpt not in metadata.get_decimal_set(): return False if metadata.get_decimal_scale() and len(str(inpt).split('.')[-1]) != metadata.get_decimal_scale(): return False else: return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_valid_decimal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '7', 'type': 'block', 'children': ['8', '25', '43', '60', '77', '94']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '22']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': '()', 'children': ['11']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '17'], 'value': 'or'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'False', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '32']}; {'id': '26', 'type': 'not_operator', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '43', 'type': 'if_statement', 'children': ['44', '57']}; {'id': '44', 'type': 'boolean_operator', 'children': ['45', '50'], 'value': 'and'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'get_minimum_decimal'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': '<'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'get_minimum_decimal'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'False', 'children': []}; {'id': '60', 'type': 'if_statement', 'children': ['61', '74']}; {'id': '61', 'type': 'boolean_operator', 'children': ['62', '67'], 'value': 'and'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'get_maximum_decimal'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': '>'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'get_maximum_decimal'}; {'id': '73', 'type': 'argument_list', 'children': []}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'False', 'children': []}; {'id': '77', 'type': 'if_statement', 'children': ['78', '91']}; {'id': '78', 'type': 'boolean_operator', 'children': ['79', '84'], 'value': 'and'}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'get_decimal_set'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': 'not in'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'get_decimal_set'}; {'id': '90', 'type': 'argument_list', 'children': []}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'False', 'children': []}; {'id': '94', 'type': 'if_statement', 'children': ['95', '122', '125']}; {'id': '95', 'type': 'boolean_operator', 'children': ['96', '101'], 'value': 'and'}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'get_decimal_scale'}; {'id': '100', 'type': 'argument_list', 'children': []}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '117'], 'value': '!='}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'subscript', 'children': ['106', '115']}; {'id': '106', 'type': 'call', 'children': ['107', '113']}; {'id': '107', 'type': 'attribute', 'children': ['108', '112']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'inpt'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '115', 'type': 'unary_operator', 'children': ['116'], 'value': '-'}; {'id': '116', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'get_decimal_scale'}; {'id': '121', 'type': 'argument_list', 'children': []}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'return_statement', 'children': ['124']}; {'id': '124', 'type': 'False', 'children': []}; {'id': '125', 'type': 'else_clause', 'children': ['126']}; {'id': '126', 'type': 'block', 'children': ['127']}; {'id': '127', 'type': 'return_statement', 'children': ['128']}; {'id': '128', 'type': 'True', 'children': []}
Checks if input is a valid decimal value
def _reformat_docstring(doc, format_fn, code_newline=""): out = [] status = {"listing": False, "add_line": False, "eat_line": False} code = False for line in doc: if status["add_line"]: out.append("\n") status["add_line"] = False if status["eat_line"]: status["eat_line"] = False if line.strip() == "": continue if line.strip() == "```": code = not code out.append(line + code_newline) continue if not code: if line.rstrip() == "": status["listing"] = False line = format_fn(line, status) if re_listing.match(line): status["listing"] = True out.append(line.rstrip() + "\n") return out
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_reformat_docstring'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'format_fn'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'code_newline'}; {'id': '8', 'type': 'string', 'children': [], 'value': '""'}; {'id': '9', 'type': 'block', 'children': ['10', '14', '27', '31', '152']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '13', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '17', 'type': 'dictionary', 'children': ['18', '21', '24']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"listing"'}; {'id': '20', 'type': 'False', 'children': []}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"add_line"'}; {'id': '23', 'type': 'False', 'children': []}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"eat_line"'}; {'id': '26', 'type': 'False', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '30', 'type': 'False', 'children': []}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '34', 'type': 'block', 'children': ['35', '47', '53', '74', '98', '139']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '39']}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"add_line"'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"add_line"'}; {'id': '52', 'type': 'False', 'children': []}; {'id': '53', 'type': 'if_statement', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '56', 'type': 'string', 'children': [], 'value': '"eat_line"'}; {'id': '57', 'type': 'block', 'children': ['58', '64']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"eat_line"'}; {'id': '63', 'type': 'False', 'children': []}; {'id': '64', 'type': 'if_statement', 'children': ['65', '72']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '71'], 'value': '=='}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '70', 'type': 'argument_list', 'children': []}; {'id': '71', 'type': 'string', 'children': [], 'value': '""'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'continue_statement', 'children': []}; {'id': '74', 'type': 'if_statement', 'children': ['75', '82']}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '81'], 'value': '=='}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'id': '81', 'type': 'string', 'children': [], 'value': '"```"'}; {'id': '82', 'type': 'block', 'children': ['83', '88', '97']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '86', 'type': 'not_operator', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '96'], 'value': '+'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'code_newline'}; {'id': '97', 'type': 'continue_statement', 'children': []}; {'id': '98', 'type': 'if_statement', 'children': ['99', '101']}; {'id': '99', 'type': 'not_operator', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '101', 'type': 'block', 'children': ['102', '117', '125']}; {'id': '102', 'type': 'if_statement', 'children': ['103', '110']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '109'], 'value': '=='}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '108', 'type': 'argument_list', 'children': []}; {'id': '109', 'type': 'string', 'children': [], 'value': '""'}; {'id': '110', 'type': 'block', 'children': ['111']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '116']}; {'id': '113', 'type': 'subscript', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '115', 'type': 'string', 'children': [], 'value': '"listing"'}; {'id': '116', 'type': 'False', 'children': []}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'format_fn'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '125', 'type': 'if_statement', 'children': ['126', '132']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 're_listing'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '132', 'type': 'block', 'children': ['133']}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '138']}; {'id': '135', 'type': 'subscript', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '137', 'type': 'string', 'children': [], 'value': '"listing"'}; {'id': '138', 'type': 'True', 'children': []}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'binary_operator', 'children': ['146', '151'], 'value': '+'}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '150', 'type': 'argument_list', 'children': []}; {'id': '151', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '152', 'type': 'return_statement', 'children': ['153']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'out'}
Go through lines of file and reformat using format_fn
def draw_rect( self, x:float, y:float, w:float, h:float, *, stroke:Color=None, stroke_width:float=1, stroke_dash:typing.Sequence=None, fill:Color=None ) -> None: pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '44', '46']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'draw_rect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13', '17', '21', '22', '27', '32', '39']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '9', 'type': 'typed_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '13', 'type': 'typed_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '15', 'type': 'type', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '17', 'type': 'typed_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '19', 'type': 'type', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '21', 'type': 'keyword_separator', 'children': []}; {'id': '22', 'type': 'typed_default_parameter', 'children': ['23', '24', '26']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'stroke'}; {'id': '24', 'type': 'type', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Color'}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'typed_default_parameter', 'children': ['28', '29', '31']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'stroke_width'}; {'id': '29', 'type': 'type', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'typed_default_parameter', 'children': ['33', '34', '38']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stroke_dash'}; {'id': '34', 'type': 'type', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'typing'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Sequence'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'typed_default_parameter', 'children': ['40', '41', '43']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fill'}; {'id': '41', 'type': 'type', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Color'}; {'id': '43', 'type': 'None', 'children': []}; {'id': '44', 'type': 'type', 'children': ['45']}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'pass_statement', 'children': []}
Draws the given rectangle.
def global_variable_action(self, text, loc, var): exshared.setpos(loc, text) if DEBUG > 0: print("GLOBAL_VAR:",var) if DEBUG == 2: self.symtab.display() if DEBUG > 2: return index = self.symtab.insert_global_var(var.name, var.type) self.codegen.global_var(var.name) return index
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'global_variable_action'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '8', 'type': 'block', 'children': ['9', '17', '47', '63', '74']}; {'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': 'exshared'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'setpos'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': '>'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'DEBUG'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'block', 'children': ['22', '28', '41']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"GLOBAL_VAR:"'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'DEBUG'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_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': 'symtab'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'if_statement', 'children': ['42', '45']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': '>'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'DEBUG'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': []}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'symtab'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'insert_global_var'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '70']}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'codegen'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'global_var'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'index'}
Code executed after recognising a global variable
def save(self, *args, **kwargs): self.text = clean_text(self.text) self.text_formatted = format_text(self.text) super(BaseUserContentModel, self).save(*args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '21', '32']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'clean_text'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'text_formatted'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format_text'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '41']}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'BaseUserContentModel'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '44']}; {'id': '42', 'type': 'list_splat', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '44', 'type': 'dictionary_splat', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Clean text and save formatted version.
def __check_submodules(self): if not os.path.exists('.git'): return with open('.gitmodules') as f: for l in f: if 'path' in l: p = l.split('=')[-1].strip() if not os.path.exists(p): raise ValueError('Submodule %s missing' % p) proc = subprocess.Popen(['git', 'submodule', 'status'], stdout=subprocess.PIPE) status, _ = proc.communicate() status = status.decode("ascii", "replace") for line in status.splitlines(): if line.startswith('-') or line.startswith('+'): raise ValueError('Submodule not clean: %s' % line)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__check_submodules'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '72', '89', '99', '109']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'.git'"}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': []}; {'id': '18', 'type': 'with_statement', 'children': ['19', '28']}; {'id': '19', 'type': 'with_clause', 'children': ['20']}; {'id': '20', 'type': 'with_item', 'children': ['21']}; {'id': '21', 'type': 'as_pattern', 'children': ['22', '26']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'.gitmodules'"}; {'id': '26', 'type': 'as_pattern_target', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'in'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'path'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '37', 'type': 'block', 'children': ['38', '54']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '41', 'type': 'call', 'children': ['42', '53']}; {'id': '42', 'type': 'attribute', 'children': ['43', '52']}; {'id': '43', 'type': 'subscript', 'children': ['44', '50']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '50', 'type': 'unary_operator', 'children': ['51'], 'value': '-'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'if_statement', 'children': ['55', '64']}; {'id': '55', 'type': 'not_operator', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'raise_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'binary_operator', 'children': ['70', '71'], 'value': '%'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'Submodule %s missing'"}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'proc'}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'Popen'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '84']}; {'id': '80', 'type': 'list', 'children': ['81', '82', '83'], 'value': "['git', 'submodule', 'status']"}; {'id': '81', 'type': 'string', 'children': [], 'value': "'git'"}; {'id': '82', 'type': 'string', 'children': [], 'value': "'submodule'"}; {'id': '83', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'PIPE'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '94']}; {'id': '91', 'type': 'pattern_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'proc'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'communicate'}; {'id': '98', 'type': 'argument_list', 'children': []}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108']}; {'id': '107', 'type': 'string', 'children': [], 'value': '"ascii"'}; {'id': '108', 'type': 'string', 'children': [], 'value': '"replace"'}; {'id': '109', 'type': 'for_statement', 'children': ['110', '111', '116']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '115', 'type': 'argument_list', 'children': []}; {'id': '116', 'type': 'block', 'children': ['117']}; {'id': '117', 'type': 'if_statement', 'children': ['118', '131']}; {'id': '118', 'type': 'boolean_operator', 'children': ['119', '125'], 'value': 'or'}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'string', 'children': [], 'value': "'+'"}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'raise_statement', 'children': ['133']}; {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'binary_operator', 'children': ['137', '138'], 'value': '%'}; {'id': '137', 'type': 'string', 'children': [], 'value': "'Submodule not clean: %s'"}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'line'}
Verify that the submodules are checked out and clean.
def dict_to_op(d, index_name, doc_type, op_type='index'): if d is None: return d op_types = ('create', 'delete', 'index', 'update') if op_type not in op_types: msg = 'Unknown operation type "{}", must be one of: {}' raise Exception(msg.format(op_type, ', '.join(op_types))) if 'id' not in d: raise Exception('"id" key not found') operation = { '_op_type': op_type, '_index': index_name, '_type': doc_type, '_id': d.pop('id'), } operation.update(d) return operation
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dict_to_op'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index_name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'doc_type'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'op_type'}; {'id': '9', 'type': 'string', 'children': [], 'value': "'index'"}; {'id': '10', 'type': 'block', 'children': ['11', '18', '26', '51', '61', '82', '89']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'op_types'}; {'id': '21', 'type': 'tuple', 'children': ['22', '23', '24', '25']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'create'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'delete'"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'index'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "'update'"}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'not in'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'op_type'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'op_types'}; {'id': '30', 'type': 'block', 'children': ['31', '35']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '34', 'type': 'string', 'children': [], 'value': '\'Unknown operation type "{}", must be one of: {}\''}; {'id': '35', 'type': 'raise_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'op_type'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "', '"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'op_types'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '55']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': 'not in'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'raise_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'string', 'children': [], 'value': '\'"id" key not found\''}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '64', 'type': 'dictionary', 'children': ['65', '68', '71', '74']}; {'id': '65', 'type': 'pair', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'_op_type'"}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'op_type'}; {'id': '68', 'type': 'pair', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': "'_index'"}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'index_name'}; {'id': '71', 'type': 'pair', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'_type'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'doc_type'}; {'id': '74', 'type': 'pair', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': "'_id'"}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'string', 'children': [], 'value': "'id'"}; {'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': 'operation'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '89', 'type': 'return_statement', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'operation'}
Create a bulk-indexing operation from the given dictionary.
def play(): with sqlite3.connect(ARGS.database) as connection: connection.text_factory = str cursor = connection.cursor() if ARGS.pattern: if not ARGS.strict: ARGS.pattern = '%{0}%'.format(ARGS.pattern) cursor.execute('SELECT * FROM Movies WHERE Name LIKE (?)', [ARGS.pattern]) try: path = sorted([row for row in cursor])[0][1] replace_map = {' ': '\\ ', '"': '\\"', "'": "\\'"} for key, val in replace_map.iteritems(): path = path.replace(key, val) os.system('{0} {1} &'.format(ARGS.player, path)) except IndexError: exit('Error: Movie not found.')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'play'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 'type': 'with_statement', 'children': ['6', '19']}; {'id': '6', 'type': 'with_clause', 'children': ['7']}; {'id': '7', 'type': 'with_item', 'children': ['8']}; {'id': '8', 'type': 'as_pattern', 'children': ['9', '17']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sqlite3'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ARGS'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '17', 'type': 'as_pattern_target', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '19', 'type': 'block', 'children': ['20', '26', '34']}; {'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': 'connection'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'text_factory'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', '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': 'connection'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ARGS'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '38', 'type': 'block', 'children': ['39', '58', '69']}; {'id': '39', 'type': 'if_statement', 'children': ['40', '44']}; {'id': '40', 'type': 'not_operator', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ARGS'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'strict'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ARGS'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'%{0}%'"}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ARGS'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'SELECT * FROM Movies WHERE Name LIKE (?)'"}; {'id': '65', 'type': 'list', 'children': ['66'], 'value': '[ARGS.pattern]'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'ARGS'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '69', 'type': 'try_statement', 'children': ['70', '134']}; {'id': '70', 'type': 'block', 'children': ['71', '86', '99', '119']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '74', 'type': 'subscript', 'children': ['75', '85']}; {'id': '75', 'type': 'subscript', 'children': ['76', '84']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'list_comprehension', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '81', 'type': 'for_in_clause', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'replace_map'}; {'id': '89', 'type': 'dictionary', 'children': ['90', '93', '96']}; {'id': '90', 'type': 'pair', 'children': ['91', '92']}; {'id': '91', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '92', 'type': 'string', 'children': [], 'value': "'\\\\ '"}; {'id': '93', 'type': 'pair', 'children': ['94', '95']}; {'id': '94', 'type': 'string', 'children': [], 'value': '\'"\''}; {'id': '95', 'type': 'string', 'children': [], 'value': '\'\\\\"\''}; {'id': '96', 'type': 'pair', 'children': ['97', '98']}; {'id': '97', 'type': 'string', 'children': [], 'value': '"\'"'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"\\\\\'"'}; {'id': '99', 'type': 'for_statement', 'children': ['100', '103', '108']}; {'id': '100', 'type': 'pattern_list', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'replace_map'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'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': 'path'}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'val'}; {'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': 'os'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'string', 'children': [], 'value': "'{0} {1} &'"}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'ARGS'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'player'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '134', 'type': 'except_clause', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'string', 'children': [], 'value': "'Error: Movie not found.'"}
Open the matched movie with a media player.
def normalize(name): ret = name.replace(':', '') ret = ret.replace('%', '') ret = ret.replace(' ', '_') return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '26', '36']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '15', 'type': 'string', 'children': [], 'value': "''"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'%'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "''"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ret'}
Normalize name for the Statsd convention
def all(self, components_in_and=True): self.components_in_and = components_in_and return [obj for obj in iter(self)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all'}; {'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': 'components_in_and'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '15']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'components_in_and'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'components_in_and'}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'list_comprehension', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '18', 'type': 'for_in_clause', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}
Return all of the results of a query in a list
def delay(self): delay = {'departure_time': None, 'departure_delay': None, 'requested_differs': None, 'remarks': self.trip_remarks, 'parts': []} if self.departure_time_actual > self.departure_time_planned: delay['departure_delay'] = self.departure_time_actual - self.departure_time_planned delay['departure_time'] = self.departure_time_actual if self.requested_time != self.departure_time_actual: delay['requested_differs'] = self.departure_time_actual for part in self.trip_parts: if part.has_delay: delay['parts'].append(part) return delay
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delay'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '27', '56', '73', '93']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'delay'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '13', '16', '19', '24']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'departure_time'"}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'pair', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'departure_delay'"}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'requested_differs'"}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'pair', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'remarks'"}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'trip_remarks'}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'parts'"}; {'id': '26', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '35']}; {'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': 'departure_time_actual'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'departure_time_planned'}; {'id': '35', 'type': 'block', 'children': ['36', '48']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'delay'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'departure_delay'"}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '45'], 'value': '-'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'departure_time_actual'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'departure_time_planned'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'delay'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'departure_time'"}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'departure_time_actual'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '64']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '61'], 'value': '!='}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'requested_time'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'departure_time_actual'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'delay'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'requested_differs'"}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'departure_time_actual'}; {'id': '73', 'type': 'for_statement', 'children': ['74', '75', '78']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'trip_parts'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'if_statement', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'has_delay'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '91']}; {'id': '86', 'type': 'attribute', 'children': ['87', '90']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'delay'}; {'id': '89', 'type': 'string', 'children': [], 'value': "'parts'"}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'delay'}
Return the delay of the train for this instance
def global_max(col_vals, index): col_vals_without_None = [x for x in col_vals if x is not None] max_col, min_col = zip(*col_vals_without_None) return max(max_col), min(min_col)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'global_max'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'col_vals'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '29']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'col_vals_without_None'}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '12', '15']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '12', 'type': 'for_in_clause', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'col_vals'}; {'id': '15', 'type': 'if_clause', 'children': ['16']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'is not'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'max_col'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'min_col'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'list_splat', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'col_vals_without_None'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'expression_list', 'children': ['31', '35']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'max_col'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'min_col'}
Returns the global maximum and minimum.
def _disambiguate_pos(self, terms, pos): candidate_map = {term: wn.synsets(term, pos=pos)[:3] for term in terms} concepts = set(c for cons in candidate_map.values() for c in cons) concepts = list(concepts) sim_mat = self._similarity_matrix(concepts) map = {} for term, cons in candidate_map.items(): if not cons: continue scores = [] for con in cons: i = concepts.index(con) scores_ = [] for term_, cons_ in candidate_map.items(): if term == term_ or not cons_: continue cons_idx = [concepts.index(c) for c in cons_] top_sim = max(sim_mat[i,cons_idx]) scores_.append(top_sim) scores.append(sum(scores_)) best_idx = np.argmax(scores) map[term] = cons[best_idx] return map
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_disambiguate_pos'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'terms'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '7', 'type': 'block', 'children': ['8', '30', '47', '54', '63', '67', '179']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'candidate_map'}; {'id': '11', 'type': 'dictionary_comprehension', 'children': ['12', '27']}; {'id': '12', 'type': 'pair', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '14', 'type': 'subscript', 'children': ['15', '24']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'wn'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'synsets'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '24', 'type': 'slice', 'children': ['25', '26']}; {'id': '25', 'type': 'colon', 'children': []}; {'id': '26', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '27', 'type': 'for_in_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'terms'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'concepts'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '35', 'type': 'generator_expression', 'children': ['36', '37', '44']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '37', 'type': 'for_in_clause', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cons'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'candidate_map'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'for_in_clause', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'cons'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'concepts'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'concepts'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sim_mat'}; {'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': '_similarity_matrix'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'concepts'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '66', 'type': 'dictionary', 'children': []}; {'id': '67', 'type': 'for_statement', 'children': ['68', '71', '76']}; {'id': '68', 'type': 'pattern_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'cons'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'candidate_map'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'block', 'children': ['77', '82', '86', '162', '171']}; {'id': '77', 'type': 'if_statement', 'children': ['78', '80']}; {'id': '78', 'type': 'not_operator', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'cons'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'continue_statement', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '85', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '86', 'type': 'for_statement', 'children': ['87', '88', '89']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'cons'}; {'id': '89', 'type': 'block', 'children': ['90', '99', '103', '152']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'concepts'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'scores_'}; {'id': '102', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '103', 'type': 'for_statement', 'children': ['104', '107', '112']}; {'id': '104', 'type': 'pattern_list', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'term_'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'cons_'}; {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'candidate_map'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '111', 'type': 'argument_list', 'children': []}; {'id': '112', 'type': 'block', 'children': ['113', '122', '135', '145']}; {'id': '113', 'type': 'if_statement', 'children': ['114', '120']}; {'id': '114', 'type': 'boolean_operator', 'children': ['115', '118'], 'value': 'or'}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': '=='}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'term_'}; {'id': '118', 'type': 'not_operator', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'cons_'}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'continue_statement', 'children': []}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'cons_idx'}; {'id': '125', 'type': 'list_comprehension', 'children': ['126', '132']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'concepts'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '132', 'type': 'for_in_clause', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'cons_'}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'top_sim'}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'subscript', 'children': ['142', '143', '144']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'sim_mat'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'cons_idx'}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'scores_'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'top_sim'}; {'id': '152', 'type': 'expression_statement', 'children': ['153']}; {'id': '153', 'type': 'call', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'call', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'scores_'}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}; {'id': '163', 'type': 'assignment', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'best_idx'}; {'id': '165', 'type': 'call', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'argmax'}; {'id': '169', 'type': 'argument_list', 'children': ['170']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'scores'}; {'id': '171', 'type': 'expression_statement', 'children': ['172']}; {'id': '172', 'type': 'assignment', 'children': ['173', '176']}; {'id': '173', 'type': 'subscript', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '176', 'type': 'subscript', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'cons'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'best_idx'}; {'id': '179', 'type': 'return_statement', 'children': ['180']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'map'}
Disambiguates a list of tokens of a given PoS.
def access_list(package): team, owner, pkg = parse_package(package) session = _get_session(team) lookup_url = "{url}/api/access/{owner}/{pkg}/".format(url=get_registry_url(team), owner=owner, pkg=pkg) response = session.get(lookup_url) data = response.json() users = data['users'] print('\n'.join(users))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'access_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '23', '43', '52', '60', '66']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '12']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'team'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'parse_package'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_get_session'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'team'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'lookup_url'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"{url}/api/access/{owner}/{pkg}/"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '37', '40']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get_registry_url'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'team'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pkg'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'lookup_url'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'users'}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'users'"}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'users'}
Print list of users who can access a package.
def dist_dir(self): if self.distribution is None: warning('Tried to access {}.dist_dir, but {}.distribution ' 'is None'.format(self, self)) exit(1) return self.distribution.dist_dir
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dist_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '31']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'distribution'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '26']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'concatenated_string', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'Tried to access {}.dist_dir, but {}.distribution '"}; {'id': '21', 'type': 'string', 'children': [], 'value': "'is None'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'distribution'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dist_dir'}
The dist dir at which to place the finished distribution.
def disable(self): self.engine.data.update(sandbox_type='none') self.pop('cloud_sandbox_settings', None) self.pop('sandbox_settings', None)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'disable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '27']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '15']}; {'id': '8', 'type': 'attribute', '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': 'engine'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'sandbox_type'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'none'"}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'cloud_sandbox_settings'"}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'sandbox_settings'"}; {'id': '34', 'type': 'None', 'children': []}
Disable the sandbox on this engine.
def evaluate_binop_logical(self, operation, left, right, **kwargs): if not operation in self.binops_logical: raise ValueError("Invalid logical binary operation '{}'".format(operation)) result = self.binops_logical[operation](left, right) return bool(result)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'evaluate_binop_logical'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '29', '41']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '18']}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '15'], 'value': 'in'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'binops_logical'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'raise_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"Invalid logical binary operation \'{}\'"'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'subscript', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'binops_logical'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'result'}
Evaluate given logical binary operation with given operands.
def secondary_spin(mass1, mass2, spin1, spin2): mass1, mass2, spin1, spin2, input_is_array = ensurearray( mass1, mass2, spin1, spin2) ss = copy.copy(spin2) mask = mass1 < mass2 ss[mask] = spin1[mask] return formatreturn(ss, input_is_array)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'secondary_spin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mass1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mass2'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'spin1'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'spin2'}; {'id': '8', 'type': 'block', 'children': ['9', '24', '33', '39', '47']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '17']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13', '14', '15', '16']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'mass1'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'mass2'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'spin1'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'spin2'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'input_is_array'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ensurearray'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22', '23']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'mass1'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'mass2'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'spin1'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'spin2'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ss'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'spin2'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': '<'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'mass1'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'mass2'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ss'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'spin1'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'formatreturn'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ss'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'input_is_array'}
Returns the dimensionless spin of the secondary mass.
def use_plenary_assessment_offered_view(self): self._object_views['assessment_offered'] = PLENARY for session in self._get_provider_sessions(): try: session.use_plenary_assessment_offered_view() except AttributeError: pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'use_plenary_assessment_offered_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '13']}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_object_views'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'assessment_offered'"}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'PLENARY'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_get_provider_sessions'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'try_statement', 'children': ['23', '30']}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'use_plenary_assessment_offered_view'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'except_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'pass_statement', 'children': []}
Pass through to provider AssessmentOfferedLookupSession.use_plenary_assessment_offered_view
def visit_AST_or(self, pattern): return any(self.field_match(self.node, value_or) for value_or in pattern.args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_AST_or'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '10', 'type': 'generator_expression', 'children': ['11', '20']}; {'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': 'field_match'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value_or'}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value_or'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'args'}
Match if any of the or content match with the other node.
def run(self): for rel_path in sorted(self.paths): file_path = join(self.data_dir, rel_path) self.minify(file_path) after = self.size_of(self.after_total) before = self.size_of(self.before_total) saved = self.size_of(self.before_total - self.after_total) template = '\nTotal: ' \ '\033[92m{}\033[0m -> \033[92m{}\033[0m. ' \ 'Compressed: \033[92m{}\033[0m\n' print(template.format(before, after, saved))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '32', '43', '54', '69', '76']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '14']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'rel_path'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '14', 'type': 'block', 'children': ['15', '25']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data_dir'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'rel_path'}; {'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': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'minify'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'after'}; {'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': 'size_of'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'after_total'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'before'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'size_of'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'before_total'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'saved'}; {'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': 'size_of'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '66'], 'value': '-'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'before_total'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'after_total'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '72', 'type': 'concatenated_string', 'children': ['73', '74', '75']}; {'id': '73', 'type': 'string', 'children': [], 'value': "'\\nTotal: '"}; {'id': '74', 'type': 'string', 'children': [], 'value': "'\\033[92m{}\\033[0m -> \\033[92m{}\\033[0m. '"}; {'id': '75', 'type': 'string', 'children': [], 'value': "'Compressed: \\033[92m{}\\033[0m\\n'"}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86', '87']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'before'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'after'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'saved'}
Start json minimizer and exit when all json files were minimized.
def IsFileStatEntry(self, original_result): return (original_result.pathspec.pathtype in [ rdf_paths.PathSpec.PathType.OS, rdf_paths.PathSpec.PathType.TSK ])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'IsFileStatEntry'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'original_result'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': '()', 'children': ['9']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '15'], 'value': 'in'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'original_result'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pathspec'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pathtype'}; {'id': '15', 'type': 'list', 'children': ['16', '23'], 'value': '[\n rdf_paths.PathSpec.PathType.OS, rdf_paths.PathSpec.PathType.TSK\n ]'}; {'id': '16', 'type': 'attribute', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'rdf_paths'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'PathSpec'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'PathType'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'OS'}; {'id': '23', 'type': 'attribute', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'rdf_paths'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'PathSpec'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'PathType'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'TSK'}
Checks if given RDFValue is a file StatEntry.
def secp256r1(): GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16)) ec = EllipticCurve(GFp, 115792089210356248762697446949407573530086143415290314195533631308867097853948, 41058363725152142129326129780047268409114441015993725554835256314039467401291) return ECDSA(ec, ec.point(0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296, 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5), GFp)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'secp256r1'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '16', '25']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'GFp'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'FiniteField'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '16'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ec'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'EllipticCurve'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'GFp'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '115792089210356248762697446949407573530086143415290314195533631308867097853948'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '41058363725152142129326129780047268409114441015993725554835256314039467401291'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ECDSA'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '37']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ec'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ec'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'point'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'GFp'}
create the secp256r1 curve
def extractSeqAndQuals(seq, quals, umi_bases, cell_bases, discard_bases, retain_umi=False): new_seq = "" new_quals = "" umi_quals = "" cell_quals = "" ix = 0 for base, qual in zip(seq, quals): if ((ix not in discard_bases) and (ix not in cell_bases)): if retain_umi: new_quals += qual new_seq += base umi_quals += qual else: if ix not in umi_bases: new_quals += qual new_seq += base else: umi_quals += qual elif ix in cell_bases: cell_quals += qual ix += 1 return new_seq, new_quals, umi_quals, cell_quals
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extractSeqAndQuals'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'seq'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'quals'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'umi_bases'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cell_bases'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'discard_bases'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'retain_umi'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '17', '21', '25', '29', '33', '104']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'new_seq'}; {'id': '16', 'type': 'string', 'children': [], 'value': '""'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'new_quals'}; {'id': '20', 'type': 'string', 'children': [], 'value': '""'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'umi_quals'}; {'id': '24', 'type': 'string', 'children': [], 'value': '""'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cell_quals'}; {'id': '28', 'type': 'string', 'children': [], 'value': '""'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '37', '42']}; {'id': '34', 'type': 'pattern_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'qual'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'seq'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'quals'}; {'id': '42', 'type': 'block', 'children': ['43', '100']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '54', '91']}; {'id': '44', 'type': '()', 'children': ['45']}; {'id': '45', 'type': 'boolean_operator', 'children': ['46', '50'], 'value': 'and'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'not in'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'discard_bases'}; {'id': '50', 'type': '()', 'children': ['51']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': 'not in'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'cell_bases'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'if_statement', 'children': ['56', '57', '70']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'retain_umi'}; {'id': '57', 'type': 'block', 'children': ['58', '62', '66']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'augmented_assignment', 'children': ['60', '61'], 'value': '+='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'new_quals'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'qual'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'augmented_assignment', 'children': ['64', '65'], 'value': '+='}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'new_seq'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'augmented_assignment', 'children': ['68', '69'], 'value': '+='}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'umi_quals'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'qual'}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'if_statement', 'children': ['73', '76', '85']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '75'], 'value': 'not in'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'umi_bases'}; {'id': '76', 'type': 'block', 'children': ['77', '81']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'augmented_assignment', 'children': ['79', '80'], 'value': '+='}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'new_quals'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'qual'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'augmented_assignment', 'children': ['83', '84'], 'value': '+='}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'new_seq'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '85', 'type': 'else_clause', 'children': ['86']}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'augmented_assignment', 'children': ['89', '90'], 'value': '+='}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'umi_quals'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'qual'}; {'id': '91', 'type': 'elif_clause', 'children': ['92', '95']}; {'id': '92', 'type': 'comparison_operator', 'children': ['93', '94'], 'value': 'in'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'cell_bases'}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'augmented_assignment', 'children': ['98', '99'], 'value': '+='}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'cell_quals'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'qual'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'augmented_assignment', 'children': ['102', '103'], 'value': '+='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'ix'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'expression_list', 'children': ['106', '107', '108', '109']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'new_seq'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'new_quals'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'umi_quals'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'cell_quals'}
Remove selected bases from seq and quals
def _empty_notification(self): sess = cherrypy.session username = sess.get(SESSION_KEY, None) if username in self.notifications: ret = self.notifications[username] else: ret = [] self.notifications[username] = [] return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_empty_notification'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '22', '43', '51']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sess'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cherrypy'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'sess'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'SESSION_KEY'}; {'id': '21', 'type': 'None', 'children': []}; {'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': 'username'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'notifications'}; {'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': 'ret'}; {'id': '32', 'type': 'subscript', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'notifications'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'username'}; {'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', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '42', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '50']}; {'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': 'notifications'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '50', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ret'}
empty and return list of message notification
def from_pillow(pil_image): pil_image = pil_image.convert('RGB') cv2_image = np.array(pil_image) cv2_image = cv2_image[:, :, ::-1].copy() return cv2_image
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_pillow'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pil_image'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '24', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'pil_image'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pil_image'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'convert'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'RGB'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cv2_image'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pil_image'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cv2_image'}; {'id': '27', 'type': 'call', 'children': ['28', '41']}; {'id': '28', 'type': 'attribute', 'children': ['29', '40']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31', '33', '35']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cv2_image'}; {'id': '31', 'type': 'slice', 'children': ['32']}; {'id': '32', 'type': 'colon', 'children': []}; {'id': '33', 'type': 'slice', 'children': ['34']}; {'id': '34', 'type': 'colon', 'children': []}; {'id': '35', 'type': 'slice', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'colon', 'children': []}; {'id': '37', 'type': 'colon', 'children': []}; {'id': '38', 'type': 'unary_operator', 'children': ['39'], 'value': '-'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cv2_image'}
Convert from pillow image to opencv
def _upgrades(self, sid, transport): if not self.allow_upgrades or self._get_socket(sid).upgraded or \ self._async['websocket'] is None or transport == 'websocket': return [] return ['websocket']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_upgrades'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '7', 'type': 'block', 'children': ['8', '38']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '35']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '32'], 'value': 'or'}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '24', '25'], 'value': 'or'}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '16'], 'value': 'or'}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'allow_upgrades'}; {'id': '16', 'type': 'attribute', 'children': ['17', '23']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_get_socket'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'upgraded'}; {'id': '24', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '31'], 'value': 'is'}; {'id': '26', 'type': 'subscript', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_async'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'websocket'"}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': '=='}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'websocket'"}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'list', 'children': ['40'], 'value': "['websocket']"}; {'id': '40', 'type': 'string', 'children': [], 'value': "'websocket'"}
Return the list of possible upgrades for a client connection.
def to_string(self): node = quote_if_necessary(self.obj_dict['name']) node_attr = list() for attr in sorted(self.obj_dict['attributes']): value = self.obj_dict['attributes'][attr] if value == '': value = '""' if value is not None: node_attr.append( '%s=%s' % (attr, quote_if_necessary(value) ) ) else: node_attr.append( attr ) if node in ('graph', 'node', 'edge') and len(node_attr) == 0: return '' node_attr = ', '.join(node_attr) if node_attr: node += ' [' + node_attr + ']' return node + ';'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '23', '81', '98', '107', '118']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'quote_if_necessary'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'obj_dict'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '33']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'obj_dict'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'attributes'"}; {'id': '33', 'type': 'block', 'children': ['34', '44', '53']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '37', 'type': 'subscript', 'children': ['38', '43']}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'obj_dict'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'attributes'"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '48']}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '47'], 'value': '=='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '47', 'type': 'string', 'children': [], 'value': "''"}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '52', 'type': 'string', 'children': [], 'value': '\'""\''}; {'id': '53', 'type': 'if_statement', 'children': ['54', '57', '72']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': 'is not'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '56', 'type': 'None', 'children': []}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'binary_operator', 'children': ['65', '66'], 'value': '%'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'%s=%s'"}; {'id': '66', 'type': 'tuple', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'quote_if_necessary'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '72', 'type': 'else_clause', 'children': ['73']}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '95']}; {'id': '82', 'type': 'boolean_operator', 'children': ['83', '89'], 'value': 'and'}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '85'], 'value': 'in'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '85', 'type': 'tuple', 'children': ['86', '87', '88']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'graph'"}; {'id': '87', 'type': 'string', 'children': [], 'value': "'node'"}; {'id': '88', 'type': 'string', 'children': [], 'value': "'edge'"}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '94'], 'value': '=='}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'string', 'children': [], 'value': "''"}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'string', 'children': [], 'value': "', '"}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '107', 'type': 'if_statement', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'augmented_assignment', 'children': ['112', '113'], 'value': '+='}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '113', 'type': 'binary_operator', 'children': ['114', '117'], 'value': '+'}; {'id': '114', 'type': 'binary_operator', 'children': ['115', '116'], 'value': '+'}; {'id': '115', 'type': 'string', 'children': [], 'value': "' ['"}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'node_attr'}; {'id': '117', 'type': 'string', 'children': [], 'value': "']'"}; {'id': '118', 'type': 'return_statement', 'children': ['119']}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '121'], 'value': '+'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '121', 'type': 'string', 'children': [], 'value': "';'"}
Return string representation of node in DOT language.
def _primary_input(self, index): primary_input = z.ZcashByteData() primary_input += self.tx_joinsplits[index].anchor primary_input += self.tx_joinsplits[index].nullifiers primary_input += self.tx_joinsplits[index].commitments primary_input += self.tx_joinsplits[index].vpub_old primary_input += self.tx_joinsplits[index].vpub_new primary_input += self.hsigs[index] primary_input += self.tx_joinsplits[index].vmacs return primary_input.to_bytes()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_primary_input'}; {'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', '15', '25', '35', '45', '55', '65', '73', '83']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ZcashByteData'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'augmented_assignment', 'children': ['17', '18'], 'value': '+='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '18', 'type': 'attribute', 'children': ['19', '24']}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tx_joinsplits'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'anchor'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'augmented_assignment', 'children': ['27', '28'], 'value': '+='}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '28', 'type': 'attribute', 'children': ['29', '34']}; {'id': '29', 'type': 'subscript', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tx_joinsplits'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'nullifiers'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'augmented_assignment', 'children': ['37', '38'], 'value': '+='}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '38', 'type': 'attribute', 'children': ['39', '44']}; {'id': '39', 'type': 'subscript', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'tx_joinsplits'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'commitments'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'augmented_assignment', 'children': ['47', '48'], 'value': '+='}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '48', 'type': 'attribute', 'children': ['49', '54']}; {'id': '49', 'type': 'subscript', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'tx_joinsplits'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'vpub_old'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'augmented_assignment', 'children': ['57', '58'], 'value': '+='}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '58', 'type': 'attribute', 'children': ['59', '64']}; {'id': '59', 'type': 'subscript', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'tx_joinsplits'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'vpub_new'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'augmented_assignment', 'children': ['67', '68'], 'value': '+='}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '68', 'type': 'subscript', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'hsigs'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'augmented_assignment', 'children': ['75', '76'], 'value': '+='}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '76', 'type': 'attribute', 'children': ['77', '82']}; {'id': '77', 'type': 'subscript', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'tx_joinsplits'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'vmacs'}; {'id': '83', 'type': 'return_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'primary_input'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'to_bytes'}; {'id': '88', 'type': 'argument_list', 'children': []}
Primary input for the zkproof
def measurement_time_typical(self): meas_time_ms = 1.0 if self.overscan_temperature != OVERSCAN_DISABLE: meas_time_ms += (2 * _BME280_OVERSCANS.get(self.overscan_temperature)) if self.overscan_pressure != OVERSCAN_DISABLE: meas_time_ms += (2 * _BME280_OVERSCANS.get(self.overscan_pressure) + 0.5) if self.overscan_humidity != OVERSCAN_DISABLE: meas_time_ms += (2 * _BME280_OVERSCANS.get(self.overscan_humidity) + 0.5) return meas_time_ms
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'measurement_time_typical'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '31', '54', '77']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'meas_time_ms'}; {'id': '9', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '10', 'type': 'if_statement', 'children': ['11', '16']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '15'], 'value': '!='}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'overscan_temperature'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'OVERSCAN_DISABLE'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'augmented_assignment', 'children': ['19', '20'], 'value': '+='}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'meas_time_ms'}; {'id': '20', 'type': '()', 'children': ['21']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '*'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_BME280_OVERSCANS'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'overscan_temperature'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '36'], 'value': '!='}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'overscan_pressure'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'OVERSCAN_DISABLE'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'augmented_assignment', 'children': ['40', '41'], 'value': '+='}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'meas_time_ms'}; {'id': '41', 'type': '()', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '53'], 'value': '+'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '*'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_BME280_OVERSCANS'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'overscan_pressure'}; {'id': '53', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '60']}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '59'], 'value': '!='}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'overscan_humidity'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'OVERSCAN_DISABLE'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'augmented_assignment', 'children': ['63', '64'], 'value': '+='}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'meas_time_ms'}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '76'], 'value': '+'}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '68'], 'value': '*'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_BME280_OVERSCANS'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'overscan_humidity'}; {'id': '76', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'meas_time_ms'}
Typical time in milliseconds required to complete a measurement in normal mode
def extract_date(value): dtime = value.to_datetime() dtime = (dtime - timedelta(hours=dtime.hour) - timedelta(minutes=dtime.minute) - timedelta(seconds=dtime.second) - timedelta(microseconds=dtime.microsecond)) return dtime
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_date'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '55']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'dtime'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'to_datetime'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dtime'}; {'id': '17', 'type': '()', 'children': ['18']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '47'], 'value': '-'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '39'], 'value': '-'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '31'], 'value': '-'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '-'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dtime'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'hours'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dtime'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'hour'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'minutes'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'dtime'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'minute'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dtime'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'second'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'microseconds'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dtime'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'microsecond'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dtime'}
Convert timestamp to datetime and set everything to zero except a date
def layers(): global _cached_layers if _cached_layers is not None: return _cached_layers layers_module = tf.layers try: from tensorflow.python import tf2 if tf2.enabled(): tf.logging.info("Running in V2 mode, using Keras layers.") layers_module = tf.keras.layers except ImportError: pass _cached_layers = layers_module return layers_module
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'layers'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '14', '20', '56', '60']}; {'id': '5', 'type': 'global_statement', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': '_cached_layers'}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is not'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_cached_layers'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_cached_layers'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'layers_module'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'layers'}; {'id': '20', 'type': 'try_statement', 'children': ['21', '52']}; {'id': '21', 'type': 'block', 'children': ['22', '28']}; {'id': '22', 'type': 'import_from_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'dotted_name', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tensorflow'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'python'}; {'id': '26', 'type': 'dotted_name', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tf2'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '34']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tf2'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'enabled'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35', '44']}; {'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': 'tf'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"Running in V2 mode, using Keras layers."'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'layers_module'}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'keras'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'layers'}; {'id': '52', 'type': 'except_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ImportError'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'pass_statement', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_cached_layers'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'layers_module'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'layers_module'}
Get the layers module good for TF 1 and TF 2 work for now.
def __get_default_settings(self): LOGGER.debug("> Accessing '{0}' default settings file!".format(UiConstants.settings_file)) self.__default_settings = QSettings( umbra.ui.common.get_resource_path(UiConstants.settings_file), QSettings.IniFormat)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_default_settings'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"> Accessing \'{0}\' default settings file!"'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'UiConstants'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'settings_file'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '__default_settings'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'QSettings'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '40']}; {'id': '28', 'type': 'call', 'children': ['29', '36']}; {'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': 'umbra'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ui'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'common'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'get_resource_path'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'UiConstants'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'settings_file'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'QSettings'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'IniFormat'}
Gets the default settings.
def sample(self, hash, limit=None, offset=None): uri = self._uris['sample'].format(hash) params = {'limit': limit, 'offset': offset} return self.get_parse(uri, params)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sample'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hash'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '26', '36']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'uri'}; {'id': '16', 'type': 'call', 'children': ['17', '24']}; {'id': '17', 'type': 'attribute', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_uris'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'sample'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hash'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '29', 'type': 'dictionary', 'children': ['30', '33']}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'limit'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'offset'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get_parse'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'uri'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'params'}
Return an object representing the sample identified by the input hash, or an empty object if that sample is not found
def applied(): upgrader = InvenioUpgrader() logger = upgrader.get_logger() try: upgrades = upgrader.get_history() if not upgrades: logger.info("No upgrades have been applied.") return logger.info("Following upgrade(s) have been applied:") for u_id, applied in upgrades: logger.info(" * %s (%s)" % (u_id, applied)) except RuntimeError as e: for msg in e.args: logger.error(unicode(msg)) raise
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'applied'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '19']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'upgrader'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'InvenioUpgrader'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'upgrader'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_logger'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'try_statement', 'children': ['20', '65']}; {'id': '20', 'type': 'block', 'children': ['21', '29', '41', '48']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'upgrades'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'upgrader'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get_history'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'if_statement', 'children': ['30', '32']}; {'id': '30', 'type': 'not_operator', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'upgrades'}; {'id': '32', 'type': 'block', 'children': ['33', '40']}; {'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': 'logger'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"No upgrades have been applied."'}; {'id': '40', 'type': 'return_statement', 'children': []}; {'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': 'logger'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"Following upgrade(s) have been applied:"'}; {'id': '48', 'type': 'for_statement', 'children': ['49', '52', '53']}; {'id': '49', 'type': 'pattern_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'u_id'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'applied'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'upgrades'}; {'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': 'logger'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '%'}; {'id': '61', 'type': 'string', 'children': [], 'value': '" * %s (%s)"'}; {'id': '62', 'type': 'tuple', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'u_id'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'applied'}; {'id': '65', 'type': 'except_clause', 'children': ['66', '70']}; {'id': '66', 'type': 'as_pattern', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '68', 'type': 'as_pattern_target', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '70', 'type': 'block', 'children': ['71', '87']}; {'id': '71', 'type': 'for_statement', 'children': ['72', '73', '76']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '87', 'type': 'raise_statement', 'children': []}
Command for showing all upgrades already applied.
def _update_gmt(self): if self.simulation_start is not None: offset_string = str(self.simulation_start.replace(tzinfo=self.tz) .utcoffset().total_seconds()/3600.) self._update_card('GMT', offset_string)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_gmt'}; {'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', '41']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'offset_string'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '40'], 'value': '/'}; {'id': '20', 'type': 'call', 'children': ['21', '39']}; {'id': '21', 'type': 'attribute', 'children': ['22', '38']}; {'id': '22', 'type': 'call', 'children': ['23', '37']}; {'id': '23', 'type': 'attribute', 'children': ['24', '36']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'simulation_start'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tzinfo'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'utcoffset'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'total_seconds'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'float', 'children': [], 'value': '3600.'}; {'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': '_update_card'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'GMT'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'offset_string'}
Based on timezone and start date, the GMT card is updated
def tokenize(self, text, context=0, skip_style_tags=False): split = self.regex.split(text) self._text = [segment for segment in split if segment] self._head = self._global = self._depth = 0 self._bad_routes = set() self._skip_style_tags = skip_style_tags try: tokens = self._parse(context) except BadRoute: raise ParserError("Python tokenizer exited with BadRoute") if self._stacks: err = "Python tokenizer exited with non-empty token stack" raise ParserError(err) return tokens
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tokenize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'skip_style_tags'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '24', '36', '50', '58', '64', '83', '97']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'split'}; {'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': 'regex'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_text'}; {'id': '29', 'type': 'list_comprehension', 'children': ['30', '31', '34']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'segment'}; {'id': '31', 'type': 'for_in_clause', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'segment'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '34', 'type': 'if_clause', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'segment'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_head'}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_global'}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_depth'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_bad_routes'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_skip_style_tags'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'skip_style_tags'}; {'id': '64', 'type': 'try_statement', 'children': ['65', '75']}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_parse'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '75', 'type': 'except_clause', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'BadRoute'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'raise_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ParserError'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'string', 'children': [], 'value': '"Python tokenizer exited with BadRoute"'}; {'id': '83', 'type': 'if_statement', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_stacks'}; {'id': '87', 'type': 'block', 'children': ['88', '92']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '91', 'type': 'string', 'children': [], 'value': '"Python tokenizer exited with non-empty token stack"'}; {'id': '92', 'type': 'raise_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'ParserError'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'tokens'}
Build a list of tokens from a string of wikicode and return it.
def parse_object(self, data): for key, value in data.items(): if isinstance(value, (str, type(u''))) and \ self.strict_iso_match.match(value): data[key] = dateutil.parser.parse(value) return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_object'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7', '52']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '11', '16']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '38']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '29', '30'], 'value': 'and'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "u''"}; {'id': '29', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'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': 'strict_iso_match'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dateutil'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'data'}
Look for datetime looking strings.
def create(cls, parent, child, relation_type, index=None): try: with db.session.begin_nested(): obj = cls(parent_id=parent.id, child_id=child.id, relation_type=relation_type, index=index) db.session.add(obj) except IntegrityError: raise Exception("PID Relation already exists.") return obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'relation_type'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '64']}; {'id': '12', 'type': 'try_statement', 'children': ['13', '56']}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'with_statement', 'children': ['15', '24']}; {'id': '15', 'type': 'with_clause', 'children': ['16']}; {'id': '16', 'type': 'with_item', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'begin_nested'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25', '47']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '36', '41', '44']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'parent_id'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'child_id'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'relation_type'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'relation_type'}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '56', 'type': 'except_clause', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'IntegrityError'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'raise_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'string', 'children': [], 'value': '"PID Relation already exists."'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'obj'}
Create a PID relation for given parent and child.
def _do_sse_request(self, path, params=None): urls = [''.join([server.rstrip('/'), path]) for server in self.servers] while urls: url = urls.pop() try: response = self.sse_session.get( url, params=params, stream=True, headers={'Accept': 'text/event-stream'}, auth=self.auth, verify=self.verify, allow_redirects=False ) except Exception as e: marathon.log.error( 'Error while calling %s: %s', url, e.message) else: if response.is_redirect and response.next: urls.append(response.next.url) marathon.log.debug("Got redirect to {}".format(response.next.url)) elif response.ok: return response.iter_lines() raise MarathonError('No remaining Marathon servers to try')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_do_sse_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '32', '151']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '13', 'type': 'list_comprehension', 'children': ['14', '27']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "''"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'list', 'children': ['20', '26'], 'value': "[server.rstrip('/'), path]"}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'for_in_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'servers'}; {'id': '32', 'type': 'while_statement', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '34', 'type': 'block', 'children': ['35', '43']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'try_statement', 'children': ['44', '81', '100']}; {'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': 'response'}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'sse_session'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56', '59', '62', '68', '73', '78']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '61', 'type': 'True', 'children': []}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '64', 'type': 'dictionary', 'children': ['65']}; {'id': '65', 'type': 'pair', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'Accept'"}; {'id': '67', 'type': 'string', 'children': [], 'value': "'text/event-stream'"}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'verify'}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'verify'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'allow_redirects'}; {'id': '80', 'type': 'False', 'children': []}; {'id': '81', 'type': 'except_clause', 'children': ['82', '86']}; {'id': '82', 'type': 'as_pattern', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '84', 'type': 'as_pattern_target', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'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': 'marathon'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96', '97']}; {'id': '95', 'type': 'string', 'children': [], 'value': "'Error while calling %s: %s'"}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '100', 'type': 'else_clause', 'children': ['101']}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'if_statement', 'children': ['103', '110', '140']}; {'id': '103', 'type': 'boolean_operator', 'children': ['104', '107'], 'value': 'and'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'is_redirect'}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '110', 'type': 'block', 'children': ['111', '122']}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'call', 'children': ['124', '129']}; {'id': '124', 'type': 'attribute', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'marathon'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'string', 'children': [], 'value': '"Got redirect to {}"'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'attribute', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '140', 'type': 'elif_clause', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'ok'}; {'id': '144', 'type': 'block', 'children': ['145']}; {'id': '145', 'type': 'return_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'iter_lines'}; {'id': '150', 'type': 'argument_list', 'children': []}; {'id': '151', 'type': 'raise_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'MarathonError'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'string', 'children': [], 'value': "'No remaining Marathon servers to try'"}
Query Marathon server for events.
def delete_subject(self, subject_id): uri = self._get_subject_uri(guid=subject_id) return self.service._delete(uri)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_subject'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'subject_id'}; {'id': '6', 'type': 'block', 'children': ['7', '18']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'uri'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_get_subject_uri'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'guid'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'subject_id'}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_delete'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'uri'}
Remove a specific subject by its identifier.
def run_commands(self, commands): if "eos" in self.profile: return list(self.parent.cli(commands).values())[0] else: raise AttributeError("MockedDriver instance has not attribute '_rpc'")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_commands'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '32']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'in'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"eos"'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'profile'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'subscript', 'children': ['16', '31']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '30']}; {'id': '20', 'type': 'attribute', 'children': ['21', '29']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cli'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'raise_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"MockedDriver instance has not attribute \'_rpc\'"'}
Only useful for EOS
def analysis_period(self): return AnalysisPeriod( self.sky_condition.month, self.sky_condition.day_of_month, 0, self.sky_condition.month, self.sky_condition.day_of_month, 23)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'analysis_period'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'AnalysisPeriod'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '15', '20', '21', '26', '31']}; {'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': 'sky_condition'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sky_condition'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'day_of_month'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'sky_condition'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'month'}; {'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': 'sky_condition'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'day_of_month'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '23'}
The analysisperiod of the design day.
def get(): uptime = time.time() - START_TIME response = dict(uptime=f'{uptime:.2f}s', links=dict(root='{}'.format(get_root_url()))) return response, HTTPStatus.OK
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '15', '39']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'uptime'}; {'id': '8', 'type': 'binary_operator', 'children': ['9', '14'], 'value': '-'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'START_TIME'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'uptime'}; {'id': '23', 'type': 'string', 'children': [], 'value': "f'{uptime:.2f}s'"}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'{}'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'get_root_url'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'expression_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'HTTPStatus'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'OK'}
Check the health of this service
def watch_firings(self, flag): lib.EnvSetDefruleWatchFirings(self._env, int(flag), self._rule)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'watch_firings'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'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': 'lib'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'EnvSetDefruleWatchFirings'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16', '20']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_env'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_rule'}
Whether or not the Rule firings are being watched.
def custom_check(cmd, ignore_retcode=False): p = custom_popen(cmd) out, _ = p.communicate() if p.returncode and not ignore_retcode: raise RarExecError("Check-run failed") return out
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'custom_check'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ignore_retcode'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '16', '26', '39']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'custom_popen'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'pattern_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'communicate'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'if_statement', 'children': ['27', '33']}; {'id': '27', 'type': 'boolean_operator', 'children': ['28', '31'], 'value': 'and'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '31', 'type': 'not_operator', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ignore_retcode'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'raise_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'RarExecError'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"Check-run failed"'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'out'}
Run command, collect output, raise error if needed.
def _get_dns_entry_trs(self): from bs4 import BeautifulSoup dns_list_response = self.session.get( self.URLS['dns'].format(self.domain_id)) self._log('DNS list', dns_list_response) assert dns_list_response.status_code == 200, \ 'Could not load DNS entries.' html = BeautifulSoup(dns_list_response.content, 'html.parser') self._log('DNS list', html) dns_table = html.find('table', {'id': 'cp_domains_dnseintraege'}) assert dns_table is not None, 'Could not find DNS entry table' def _is_zone_tr(elm): has_ondblclick = elm.has_attr('ondblclick') has_class = elm.has_attr('class') return elm.name.lower() == 'tr' and (has_class or has_ondblclick) rows = dns_table.findAll(_is_zone_tr) assert rows is not None and rows, 'Could not find any DNS entries' return rows
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_dns_entry_trs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '33', '41', '48', '58', '66', '79', '84', '122', '131', '138']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bs4'}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'BeautifulSoup'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dns_list_response'}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '29']}; {'id': '22', 'type': 'attribute', 'children': ['23', '28']}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'URLS'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'dns'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'domain_id'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'DNS list'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'dns_list_response'}; {'id': '41', 'type': 'assert_statement', 'children': ['42', '47']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '46'], 'value': '=='}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dns_list_response'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'Could not load DNS entries.'"}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'BeautifulSoup'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'dns_list_response'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'html.parser'"}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'DNS list'"}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'dns_table'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'string', 'children': [], 'value': "'table'"}; {'id': '75', 'type': 'dictionary', 'children': ['76']}; {'id': '76', 'type': 'pair', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '78', 'type': 'string', 'children': [], 'value': "'cp_domains_dnseintraege'"}; {'id': '79', 'type': 'assert_statement', 'children': ['80', '83']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'is not'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'dns_table'}; {'id': '82', 'type': 'None', 'children': []}; {'id': '83', 'type': 'string', 'children': [], 'value': "'Could not find DNS entry table'"}; {'id': '84', 'type': 'function_definition', 'children': ['85', '86', '88']}; {'id': '85', 'type': 'function_name', 'children': [], 'value': '_is_zone_tr'}; {'id': '86', 'type': 'parameters', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'elm'}; {'id': '88', 'type': 'block', 'children': ['89', '98', '107']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'has_ondblclick'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'elm'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'has_attr'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'string', 'children': [], 'value': "'ondblclick'"}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'has_class'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'elm'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'has_attr'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'string', 'children': [], 'value': "'class'"}; {'id': '107', 'type': 'return_statement', 'children': ['108']}; {'id': '108', 'type': 'boolean_operator', 'children': ['109', '118'], 'value': 'and'}; {'id': '109', 'type': 'comparison_operator', 'children': ['110', '117'], 'value': '=='}; {'id': '110', 'type': 'call', 'children': ['111', '116']}; {'id': '111', 'type': 'attribute', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'elm'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '116', 'type': 'argument_list', 'children': []}; {'id': '117', 'type': 'string', 'children': [], 'value': "'tr'"}; {'id': '118', 'type': '()', 'children': ['119']}; {'id': '119', 'type': 'boolean_operator', 'children': ['120', '121'], 'value': 'or'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'has_class'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'has_ondblclick'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'dns_table'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'findAll'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '_is_zone_tr'}; {'id': '131', 'type': 'assert_statement', 'children': ['132', '137']}; {'id': '132', 'type': 'boolean_operator', 'children': ['133', '136'], 'value': 'and'}; {'id': '133', 'type': 'comparison_operator', 'children': ['134', '135'], 'value': 'is not'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '135', 'type': 'None', 'children': []}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '137', 'type': 'string', 'children': [], 'value': "'Could not find any DNS entries'"}; {'id': '138', 'type': 'return_statement', 'children': ['139']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'rows'}
Return the TR elements holding the DNS entries.
def _FlushInput(self): self.ser.flush() flushed = 0 while True: ready_r, ready_w, ready_x = select.select([self.ser], [], [self.ser], 0) if len(ready_x) > 0: logging.error("Exception from serial port.") return None elif len(ready_r) > 0: flushed += 1 self.ser.read(1) self.ser.flush() else: break
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_FlushInput'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '18']}; {'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': 'ser'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'flushed'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'while_statement', 'children': ['19', '20']}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '42']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '27']}; {'id': '23', 'type': 'pattern_list', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ready_r'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ready_w'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ready_x'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '36', '37', '41']}; {'id': '32', 'type': 'list', 'children': ['33'], 'value': '[self.ser]'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ser'}; {'id': '36', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '37', 'type': 'list', 'children': ['38'], 'value': '[self.ser]'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ser'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '49', '59', '88']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '48'], 'value': '>'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ready_x'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '49', 'type': 'block', 'children': ['50', '57']}; {'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': 'logging'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'string', 'children': [], 'value': '"Exception from serial port."'}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'None', 'children': []}; {'id': '59', 'type': 'elif_clause', 'children': ['60', '66']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '65'], 'value': '>'}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'ready_r'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'block', 'children': ['67', '71', '80']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'augmented_assignment', 'children': ['69', '70'], 'value': '+='}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'flushed'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '78']}; {'id': '73', 'type': 'attribute', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ser'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '87']}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ser'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '87', 'type': 'argument_list', 'children': []}; {'id': '88', 'type': 'else_clause', 'children': ['89']}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'break_statement', 'children': []}
Flush all read data until no more available.
def _debug_line(linenum: int, line: str, extramsg: str = "") -> None: log.critical("{}Line {}: {!r}", extramsg, linenum, line)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_debug_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'linenum'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '12', 'type': 'typed_default_parameter', 'children': ['13', '14', '16']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'extramsg'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'string', 'children': [], 'value': '""'}; {'id': '17', 'type': 'type', 'children': ['18']}; {'id': '18', 'type': 'None', 'children': []}; {'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': 'log'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'critical'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '28', '29']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"{}Line {}: {!r}"'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'extramsg'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'linenum'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'line'}
Writes a debugging report on a line.
def objectprep(self): self.runmetadata = createobject.ObjectCreation(self) if self.extension == 'fastq': logging.info('Decompressing and combining .fastq files for CLARK analysis') fileprep.Fileprep(self) else: logging.info('Using .fasta files for CLARK analysis') for sample in self.runmetadata.samples: sample.general.combined = sample.general.fastqfiles[0]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'objectprep'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'runmetadata'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'createobject'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ObjectCreation'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23', '38']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': '=='}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'extension'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'fastq'"}; {'id': '23', 'type': 'block', 'children': ['24', '31']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'Decompressing and combining .fastq files for CLARK analysis'"}; {'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': 'fileprep'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Fileprep'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40', '47']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'Using .fasta files for CLARK analysis'"}; {'id': '47', 'type': 'for_statement', 'children': ['48', '49', '54']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'runmetadata'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'samples'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '62', 'type': 'subscript', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'fastqfiles'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '0'}
Create objects to store data and metadata for each sample. Also, perform necessary file manipulations
def lex(filename): with io.open(filename, mode='r', encoding='utf-8') as f: it = _lex_file_object(f) it = _balance_braces(it, filename) for token, line, quoted in it: yield (token, line, quoted)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lex'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '24']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'as_pattern', 'children': ['10', '22']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'io'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '19']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '22', 'type': 'as_pattern_target', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '24', 'type': 'block', 'children': ['25', '32', '40']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_lex_file_object'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_balance_braces'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '40', 'type': 'for_statement', 'children': ['41', '45', '46']}; {'id': '41', 'type': 'pattern_list', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'quoted'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'yield', 'children': ['49']}; {'id': '49', 'type': 'tuple', 'children': ['50', '51', '52']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'quoted'}
Generates tokens from an nginx config file
def influx_query_(self, q): if self.influx_cli is None: self.err( self.influx_query_, "No database connected. Please initialize a connection") return try: return self.influx_cli.query(q) except Exception as e: self.err(e, self.influx_query_, "Can not query database")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'influx_query_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'influx_cli'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '24']}; {'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': 'err'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'influx_query_'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"No database connected. Please initialize a connection"'}; {'id': '24', 'type': 'return_statement', 'children': []}; {'id': '25', 'type': 'try_statement', 'children': ['26', '36']}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'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': 'influx_cli'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '36', 'type': 'except_clause', 'children': ['37', '41']}; {'id': '37', 'type': 'as_pattern', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '39', 'type': 'as_pattern_target', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49', '52']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'influx_query_'}; {'id': '52', 'type': 'string', 'children': [], 'value': '"Can not query database"'}
Runs an Influx db query
def create_loadfile(entities, f): with open(f, 'w') as out: out.write(Entity.create_payload(entities))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_loadfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'entities'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'as_pattern', 'children': ['11', '16']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '16', 'type': 'as_pattern_target', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Entity'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'create_payload'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'entities'}
Create payload and save to file.
def rand_alphastr(length, lower=True, upper=True): if lower is True and upper is True: return rand_str(length, allowed=string.ascii_letters) if lower is True and upper is False: return rand_str(length, allowed=string.ascii_lowercase) if lower is False and upper is True: return rand_str(length, allowed=string.ascii_uppercase) else: raise Exception
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rand_alphastr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '31', '50']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '20']}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '17'], 'value': 'and'}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'is'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '16', 'type': 'True', 'children': []}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'is'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'rand_str'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'allowed'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ascii_letters'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '39']}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '36'], 'value': 'and'}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'is'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '35', 'type': 'True', 'children': []}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'is'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '38', 'type': 'False', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'rand_str'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'allowed'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ascii_lowercase'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '58', '69']}; {'id': '51', 'type': 'boolean_operator', 'children': ['52', '55'], 'value': 'and'}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': 'is'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '54', 'type': 'False', 'children': []}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '57'], 'value': 'is'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '57', 'type': 'True', 'children': []}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'rand_str'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'allowed'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ascii_uppercase'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'raise_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'Exception'}
Generate fixed-length random alpha only string.
def rebin2x2(a): inshape = np.array(a.shape) if not (inshape % 2 == np.zeros(2)).all(): raise RuntimeError, "I want even image shapes !" return rebin(a, inshape/2)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rebin2x2'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '39']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'inshape'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '34']}; {'id': '18', 'type': 'not_operator', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '33']}; {'id': '20', 'type': 'attribute', 'children': ['21', '32']}; {'id': '21', 'type': '()', 'children': ['22']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '26'], 'value': '=='}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '%'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'inshape'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'raise_statement', 'children': ['36']}; {'id': '36', 'type': 'expression_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"I want even image shapes !"'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'rebin'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '/'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'inshape'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '2'}
Wrapper around rebin that actually rebins 2 by 2
def stream_url(self): rtsp_url = RTSP_URL.format( host=self.config.host, video=self.video_query, audio=self.audio_query, event=self.event_query) _LOGGER.debug(rtsp_url) return rtsp_url
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stream_url'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '36', '43']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'rtsp_url'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'RTSP_URL'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '21', '26', '31']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'host'}; {'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': 'config'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'video'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'video_query'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'audio'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'audio_query'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'event_query'}; {'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': '_LOGGER'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'rtsp_url'}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'rtsp_url'}
Build url for stream.
def validate_required_attributes(fully_qualified_name: str, spec: Dict[str, Any], *attributes: str) -> List[RequiredAttributeError]: return [ RequiredAttributeError(fully_qualified_name, spec, attribute) for attribute in attributes if attribute not in spec ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_required_attributes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '18']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fully_qualified_name'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'generic_type', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Dict'}; {'id': '13', 'type': 'type_parameter', 'children': ['14', '16']}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Any'}; {'id': '18', 'type': 'typed_parameter', 'children': ['19', '21']}; {'id': '19', 'type': 'list_splat_pattern', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '21', 'type': 'type', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '23', 'type': 'type', 'children': ['24']}; {'id': '24', 'type': 'generic_type', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '26', 'type': 'type_parameter', 'children': ['27']}; {'id': '27', 'type': 'type', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'RequiredAttributeError'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'list_comprehension', 'children': ['32', '38', '41']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'RequiredAttributeError'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'fully_qualified_name'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '38', 'type': 'for_in_clause', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '41', 'type': 'if_clause', 'children': ['42']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'not in'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'spec'}
Validates to ensure that a set of attributes are present in spec
def select_molecules(name): mol_formula = current_system().get_derived_molecule_array('formula') mask = mol_formula == name ind = current_system().mol_to_atom_indices(mask.nonzero()[0]) selection = {'atoms': Selection(ind, current_system().n_atoms)} b = current_system().bonds if len(b) == 0: selection['bonds'] = Selection([], 0) else: molbonds = np.zeros(len(b), 'bool') for i in ind: matching = (i == b).sum(axis=1).astype('bool') molbonds[matching] = True selection['bonds'] = Selection(molbonds.nonzero()[0], len(b)) return select_selection(selection)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_molecules'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '23', '40', '55', '63', '144']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'mol_formula'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'current_system'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_derived_molecule_array'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'formula'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': '=='}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'mol_formula'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'current_system'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'mol_to_atom_indices'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'subscript', 'children': ['34', '39']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '43', 'type': 'dictionary', 'children': ['44']}; {'id': '44', 'type': 'pair', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'atoms'"}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'Selection'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'current_system'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'n_atoms'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'current_system'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'bonds'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '70', '81']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '69'], 'value': '=='}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '76']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'bonds'"}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'Selection'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '81', 'type': 'else_clause', 'children': ['82']}; {'id': '82', 'type': 'block', 'children': ['83', '96', '125']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'molbonds'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '95']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '95', 'type': 'string', 'children': [], 'value': "'bool'"}; {'id': '96', 'type': 'for_statement', 'children': ['97', '98', '99']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '99', 'type': 'block', 'children': ['100', '119']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'matching'}; {'id': '103', 'type': 'call', 'children': ['104', '117']}; {'id': '104', 'type': 'attribute', 'children': ['105', '116']}; {'id': '105', 'type': 'call', 'children': ['106', '112']}; {'id': '106', 'type': 'attribute', 'children': ['107', '111']}; {'id': '107', 'type': '()', 'children': ['108']}; {'id': '108', 'type': 'comparison_operator', 'children': ['109', '110'], 'value': '=='}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '115', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'astype'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'string', 'children': [], 'value': "'bool'"}; {'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': 'molbonds'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'matching'}; {'id': '124', 'type': 'True', 'children': []}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'assignment', 'children': ['127', '130']}; {'id': '127', 'type': 'subscript', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '129', 'type': 'string', 'children': [], 'value': "'bonds'"}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'Selection'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '140']}; {'id': '133', 'type': 'subscript', 'children': ['134', '139']}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'molbonds'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '138', 'type': 'argument_list', 'children': []}; {'id': '139', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '140', 'type': 'call', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '144', 'type': 'return_statement', 'children': ['145']}; {'id': '145', 'type': 'call', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'select_selection'}; {'id': '147', 'type': 'argument_list', 'children': ['148']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'selection'}
Select all the molecules corresponding to the formulas.