code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
async def send(self, *args, **kwargs):
if not self.frozen:
raise RuntimeError("Cannot send non-frozen signal.")
for receiver in self:
await receiver(*args, **kwargs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send'}; {'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']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '15']}; {'id': '11', 'type': 'not_operator', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'frozen'}; {'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': 'RuntimeError'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Cannot send non-frozen signal."'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'receiver'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'await', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'receiver'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '32']}; {'id': '30', 'type': 'list_splat', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '32', 'type': 'dictionary_splat', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Sends data to all registered receivers.
|
def main(directories):
msg = 'Checking module "{}" from directory "{}" for coding errors.'
api_checker = ApiChecker()
resource_checker = ResourceChecker()
errors = []
modules = []
for loader, mname, _ in pkgutil.walk_packages(directories):
sys.path.append(os.path.abspath(loader.path))
log.info(msg.format(mname, loader.path))
modules.append(mname)
import_module(mname)
for api in Api:
if api.__module__.split('.')[-1] not in modules:
continue
log.debug('Anlysing Api class: {}'.format(api.__name__))
errors.extend(api_checker(api))
for res in Resource:
if res.__module__.split('.')[-1] not in modules:
continue
log.debug('Anlysing Resource class: {}'.format(res.__name__))
errors.extend(resource_checker(res))
else:
log.info('All modules tested, no problem detected.')
return errors
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '16', '22', '26', '30', '87', '131', '184']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '9', 'type': 'string', 'children': [], 'value': '\'Checking module "{}" from directory "{}" for coding errors.\''}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'api_checker'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ApiChecker'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'resource_checker'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ResourceChecker'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '29', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '35', '41']}; {'id': '31', 'type': 'pattern_list', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'mname'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pkgutil'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'walk_packages'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '41', 'type': 'block', 'children': ['42', '60', '75', '82']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'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': 'os'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'abspath'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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': 'info'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'mname'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'mname'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'import_module'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'mname'}; {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '90']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'Api'}; {'id': '90', 'type': 'block', 'children': ['91', '107', '121']}; {'id': '91', 'type': 'if_statement', 'children': ['92', '105']}; {'id': '92', 'type': 'comparison_operator', 'children': ['93', '104'], 'value': 'not in'}; {'id': '93', 'type': 'subscript', 'children': ['94', '102']}; {'id': '94', 'type': 'call', 'children': ['95', '100']}; {'id': '95', 'type': 'attribute', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': '__module__'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '102', 'type': 'unary_operator', 'children': ['103'], 'value': '-'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'continue_statement', 'children': []}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'string', 'children': [], 'value': "'Anlysing Api class: {}'"}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'api_checker'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '131', 'type': 'for_statement', 'children': ['132', '133', '134', '175']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'Resource'}; {'id': '134', 'type': 'block', 'children': ['135', '151', '165']}; {'id': '135', 'type': 'if_statement', 'children': ['136', '149']}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '148'], 'value': 'not in'}; {'id': '137', 'type': 'subscript', 'children': ['138', '146']}; {'id': '138', 'type': 'call', 'children': ['139', '144']}; {'id': '139', 'type': 'attribute', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': '__module__'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '146', 'type': 'unary_operator', 'children': ['147'], 'value': '-'}; {'id': '147', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'continue_statement', 'children': []}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'string', 'children': [], 'value': "'Anlysing Resource class: {}'"}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'call', 'children': ['167', '170']}; {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}; {'id': '171', 'type': 'call', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'resource_checker'}; {'id': '173', 'type': 'argument_list', 'children': ['174']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '175', 'type': 'else_clause', 'children': ['176']}; {'id': '176', 'type': 'block', 'children': ['177']}; {'id': '177', 'type': 'expression_statement', 'children': ['178']}; {'id': '178', 'type': 'call', 'children': ['179', '182']}; {'id': '179', 'type': 'attribute', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '182', 'type': 'argument_list', 'children': ['183']}; {'id': '183', 'type': 'string', 'children': [], 'value': "'All modules tested, no problem detected.'"}; {'id': '184', 'type': 'return_statement', 'children': ['185']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'errors'}
|
Perform all checks on the API's contained in `directory`.
|
def _from_string(cls, serialized):
course_key = CourseLocator._from_string(serialized)
parsed_parts = cls.parse_url(serialized)
block_id = parsed_parts.get('block_id', None)
if block_id is None:
raise InvalidKeyError(cls, serialized)
return cls(course_key, parsed_parts.get('block_type'), block_id)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_string'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'serialized'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '35', '46']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'course_key'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'CourseLocator'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_from_string'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'serialized'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parsed_parts'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'parse_url'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'serialized'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'block_id'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'parsed_parts'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'block_id'"}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '39']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'is'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'block_id'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'raise_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'InvalidKeyError'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'serialized'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51', '57']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'course_key'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'parsed_parts'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'block_type'"}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'block_id'}
|
Requests CourseLocator to deserialize its part and then adds the local deserialization of block
|
def load_data_to_net(net, inst_net):
net.dat['nodes'] = inst_net['nodes']
net.dat['mat'] = inst_net['mat']
data_formats.mat_to_numpy_arr(net)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_data_to_net'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'inst_net'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '27']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '14']}; {'id': '9', 'type': 'subscript', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dat'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'nodes'"}; {'id': '14', 'type': 'subscript', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'inst_net'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'nodes'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '24']}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dat'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'mat'"}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'inst_net'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'mat'"}; {'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': 'data_formats'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'mat_to_numpy_arr'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'net'}
|
load data into nodes and mat, also convert mat to numpy array
|
def close(self, code: int = None, reason: str = None) -> None:
if not self.server_terminated:
if not self.stream.closed():
if code is None and reason is not None:
code = 1000
if code is None:
close_data = b""
else:
close_data = struct.pack(">H", code)
if reason is not None:
close_data += utf8(reason)
try:
self._write_frame(True, 0x8, close_data)
except StreamClosedError:
self._abort()
self.server_terminated = True
if self.client_terminated:
if self._waiting is not None:
self.stream.io_loop.remove_timeout(self._waiting)
self._waiting = None
self.stream.close()
elif self._waiting is None:
self._waiting = self.stream.io_loop.add_timeout(
self.stream.io_loop.time() + 5, self._abort
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_default_parameter', 'children': ['6', '7', '9']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'typed_default_parameter', 'children': ['11', '12', '14']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'type', 'children': ['16']}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '106']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '23']}; {'id': '19', 'type': 'not_operator', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'server_terminated'}; {'id': '23', 'type': 'block', 'children': ['24', '100']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '33']}; {'id': '25', 'type': 'not_operator', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'closed'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'block', 'children': ['34', '47', '68', '80']}; {'id': '34', 'type': 'if_statement', 'children': ['35', '42']}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '39'], 'value': 'and'}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'is'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': 'is not'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '51', '56']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'is'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '50', 'type': 'None', 'children': []}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'close_data'}; {'id': '55', 'type': 'string', 'children': [], 'value': 'b""'}; {'id': '56', 'type': 'else_clause', 'children': ['57']}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'close_data'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': '">H"'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '68', 'type': 'if_statement', 'children': ['69', '72']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71'], 'value': 'is not'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '71', 'type': 'None', 'children': []}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'augmented_assignment', 'children': ['75', '76'], 'value': '+='}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'close_data'}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'utf8'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '80', 'type': 'try_statement', 'children': ['81', '91']}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_write_frame'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89', '90']}; {'id': '88', 'type': 'True', 'children': []}; {'id': '89', 'type': 'integer', 'children': [], 'value': '0x8'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'close_data'}; {'id': '91', 'type': 'except_clause', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'StreamClosedError'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': '_abort'}; {'id': '99', 'type': 'argument_list', 'children': []}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'server_terminated'}; {'id': '105', 'type': 'True', 'children': []}; {'id': '106', 'type': 'if_statement', 'children': ['107', '110', '145']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'client_terminated'}; {'id': '110', 'type': 'block', 'children': ['111', '137']}; {'id': '111', 'type': 'if_statement', 'children': ['112', '117']}; {'id': '112', 'type': 'comparison_operator', 'children': ['113', '116'], 'value': 'is not'}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': '_waiting'}; {'id': '116', 'type': 'None', 'children': []}; {'id': '117', 'type': 'block', 'children': ['118', '131']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '127']}; {'id': '120', 'type': 'attribute', 'children': ['121', '126']}; {'id': '121', 'type': 'attribute', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'io_loop'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'remove_timeout'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '_waiting'}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': '_waiting'}; {'id': '136', 'type': 'None', 'children': []}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '144']}; {'id': '139', 'type': 'attribute', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '144', 'type': 'argument_list', 'children': []}; {'id': '145', 'type': 'elif_clause', 'children': ['146', '151']}; {'id': '146', 'type': 'comparison_operator', 'children': ['147', '150'], 'value': 'is'}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': '_waiting'}; {'id': '150', 'type': 'None', 'children': []}; {'id': '151', 'type': 'block', 'children': ['152']}; {'id': '152', 'type': 'expression_statement', 'children': ['153']}; {'id': '153', 'type': 'assignment', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': '_waiting'}; {'id': '157', 'type': 'call', 'children': ['158', '165']}; {'id': '158', 'type': 'attribute', 'children': ['159', '164']}; {'id': '159', 'type': 'attribute', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'io_loop'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'add_timeout'}; {'id': '165', 'type': 'argument_list', 'children': ['166', '177']}; {'id': '166', 'type': 'binary_operator', 'children': ['167', '176'], 'value': '+'}; {'id': '167', 'type': 'call', 'children': ['168', '175']}; {'id': '168', 'type': 'attribute', 'children': ['169', '174']}; {'id': '169', 'type': 'attribute', 'children': ['170', '173']}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'io_loop'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '175', 'type': 'argument_list', 'children': []}; {'id': '176', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '179', 'type': 'identifier', 'children': [], 'value': '_abort'}
|
Closes the WebSocket connection.
|
def remove_checksum(path):
path = '{}.md5sum'.format(path)
if os.path.exists(path):
os.remove(path)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_checksum'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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': 'path'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'{}.md5sum'"}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '24']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'path'}
|
Remove the checksum of an image from cache if exists
|
def grow(self):
"Add another worker to the pool."
t = self.worker_factory(self)
t.start()
self._size += 1
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'grow'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '17', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Add another worker to the pool."'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 't'}; {'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': 'worker_factory'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'augmented_assignment', 'children': ['25', '28'], 'value': '+='}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_size'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}
|
Add another worker to the pool.
|
async def set_config(self, on=None, long=None, lat=None,
sunriseoffset=None, sunsetoffset=None):
data = {
key: value for key, value in {
'on': on,
'long': long,
'lat': lat,
'sunriseoffset': sunriseoffset,
'sunsetoffset': sunsetoffset,
}.items() if value is not None
}
await self._request('put', 'sensors/{}/config'.format(self.id),
json=data)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'long'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sunriseoffset'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sunsetoffset'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '56']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'dictionary_comprehension', 'children': ['25', '28', '52']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '28', 'type': 'for_in_clause', 'children': ['29', '32']}; {'id': '29', 'type': 'pattern_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '32', 'type': 'call', 'children': ['33', '51']}; {'id': '33', 'type': 'attribute', 'children': ['34', '50']}; {'id': '34', 'type': 'dictionary', 'children': ['35', '38', '41', '44', '47']}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'on'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '38', 'type': 'pair', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'long'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'long'}; {'id': '41', 'type': 'pair', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'lat'"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '44', 'type': 'pair', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'sunriseoffset'"}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sunriseoffset'}; {'id': '47', 'type': 'pair', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'sunsetoffset'"}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sunsetoffset'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'if_clause', 'children': ['53']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': 'is not'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'await', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': '_request'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64', '72']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'put'"}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'sensors/{}/config'"}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'data'}
|
Change config of a Daylight sensor.
|
def _earth_orientation(date):
ttt = date.change_scale('TT').julian_century
s_prime = - 0.000047 * ttt
return date.eop.x / 3600., date.eop.y / 3600., s_prime / 3600
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_earth_orientation'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ttt'}; {'id': '9', 'type': 'attribute', 'children': ['10', '16']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'change_scale'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'TT'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'julian_century'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 's_prime'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '23'], 'value': '*'}; {'id': '21', 'type': 'unary_operator', 'children': ['22'], 'value': '-'}; {'id': '22', 'type': 'float', 'children': [], 'value': '0.000047'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ttt'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'expression_list', 'children': ['26', '33', '40']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '32'], 'value': '/'}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'eop'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'float', 'children': [], 'value': '3600.'}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '39'], 'value': '/'}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'eop'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '39', 'type': 'float', 'children': [], 'value': '3600.'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '/'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 's_prime'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '3600'}
|
Earth orientation parameters in degrees
|
def expanded_transform(self):
segments = self._expand_transform(self.transform)
if segments:
segments[0]['datatype'] = self.valuetype_class
for s in segments:
s['column'] = self
else:
segments = [self.make_xform_seg(datatype=self.valuetype_class, column=self)]
return segments
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expanded_transform'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '59']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'segments'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_expand_transform'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'transform'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '19', '40']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'segments'}; {'id': '19', 'type': 'block', 'children': ['20', '30']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '27']}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'segments'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'datatype'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'valuetype_class'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'segments'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '39']}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'column'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'segments'}; {'id': '45', 'type': 'list', 'children': ['46'], 'value': '[self.make_xform_seg(datatype=self.valuetype_class, column=self)]'}; {'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': 'make_xform_seg'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '56']}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'valuetype_class'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'segments'}
|
Expands the transform string into segments
|
def callback(self, provider):
provider = self.get_provider(provider)
try:
return provider.authorized_handler(self.login)(provider=provider)
except OAuthException as ex:
logging.error("Data: %s", ex.data)
raise
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'callback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'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_provider'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '16', 'type': 'try_statement', 'children': ['17', '32']}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '28']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'authorized_handler'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'login'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '32', 'type': 'except_clause', 'children': ['33', '37']}; {'id': '33', 'type': 'as_pattern', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'OAuthException'}; {'id': '35', 'type': 'as_pattern_target', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '37', 'type': 'block', 'children': ['38', '48']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"Data: %s"'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '48', 'type': 'raise_statement', 'children': []}
|
Handles 3rd party callback and processes it's data
|
async def home_z(self, mount: top_types.Mount = None):
if not mount:
axes = [Axis.Z, Axis.A]
else:
axes = [Axis.by_mount(mount)]
await self.home(axes)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'home_z'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_default_parameter', 'children': ['6', '7', '11']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'mount'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'top_types'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Mount'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '39']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '16', '27']}; {'id': '14', 'type': 'not_operator', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'mount'}; {'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': 'axes'}; {'id': '20', 'type': 'list', 'children': ['21', '24'], 'value': '[Axis.Z, Axis.A]'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Axis'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Z'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Axis'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '27', 'type': 'else_clause', 'children': ['28']}; {'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': 'axes'}; {'id': '32', 'type': 'list', 'children': ['33'], 'value': '[Axis.by_mount(mount)]'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Axis'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'by_mount'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'mount'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'await', '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': 'home'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'axes'}
|
Home the two z-axes
|
def open( self, **kwargs ):
if self.tag in self.parent.twotags or self.tag in self.parent.onetags:
self.render( self.tag, False, None, kwargs )
elif self.mode == 'strict_html' and self.tag in self.parent.deptags:
raise DeprecationError( self.tag )
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '28', '41']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '19'], 'value': 'or'}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '14'], 'value': 'in'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'twotags'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '23'], 'value': 'in'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'onetags'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '38', '39', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '38', 'type': 'False', 'children': []}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '41', 'type': 'elif_clause', 'children': ['42', '57']}; {'id': '42', 'type': 'boolean_operator', 'children': ['43', '48'], 'value': 'and'}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': '=='}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'strict_html'"}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '52'], 'value': 'in'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'deptags'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'raise_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'DeprecationError'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'tag'}
|
Append an opening tag.
|
def render_label(content, label_for=None, label_class=None, label_title=""):
attrs = {}
if label_for:
attrs["for"] = label_for
if label_class:
attrs["class"] = label_class
if label_title:
attrs["title"] = label_title
return render_tag("label", attrs=attrs, content=content)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_label'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'label_for'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'label_class'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'label_title'}; {'id': '13', 'type': 'string', 'children': [], 'value': '""'}; {'id': '14', 'type': 'block', 'children': ['15', '19', '28', '37', '46']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '18', 'type': 'dictionary', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'label_for'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"for"'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'label_for'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'label_class'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '35', 'type': 'string', 'children': [], 'value': '"class"'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'label_class'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'label_title'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"title"'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'label_title'}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'render_tag'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51', '54']}; {'id': '50', 'type': 'string', 'children': [], 'value': '"label"'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'content'}
|
Render a label with content
|
def draw_commands(self, surf):
past_abilities = {act.ability for act in self._past_actions if act.ability}
for y, cmd in enumerate(sorted(self._abilities(
lambda c: c.name != "Smart"), key=lambda c: c.name), start=2):
if self._queued_action and cmd == self._queued_action:
color = colors.green
elif self._queued_hotkey and cmd.hotkey.startswith(self._queued_hotkey):
color = colors.green * 0.75
elif cmd.ability_id in past_abilities:
color = colors.red
else:
color = colors.yellow
hotkey = cmd.hotkey[0:3]
surf.write_screen(self._font_large, color, (0.2, y), hotkey)
surf.write_screen(self._font_large, color, (3, y), cmd.name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'draw_commands'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'surf'}; {'id': '6', 'type': 'block', 'children': ['7', '23']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'past_abilities'}; {'id': '10', 'type': 'set_comprehension', 'children': ['11', '14', '19']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'act'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ability'}; {'id': '14', 'type': 'for_in_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'act'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_past_actions'}; {'id': '19', 'type': 'if_clause', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'act'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ability'}; {'id': '23', 'type': 'for_statement', 'children': ['24', '27', '57']}; {'id': '24', 'type': 'pattern_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '54']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '46']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_abilities'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'lambda', 'children': ['39', '41']}; {'id': '39', 'type': 'lambda_parameters', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '45'], 'value': '!='}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"Smart"'}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '48', 'type': 'lambda', 'children': ['49', '51']}; {'id': '49', 'type': 'lambda_parameters', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '57', 'type': 'block', 'children': ['58', '120', '131', '145']}; {'id': '58', 'type': 'if_statement', 'children': ['59', '68', '75', '99', '112']}; {'id': '59', 'type': 'boolean_operator', 'children': ['60', '63'], 'value': 'and'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_queued_action'}; {'id': '63', 'type': 'comparison_operator', 'children': ['64', '65'], 'value': '=='}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_queued_action'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'green'}; {'id': '75', 'type': 'elif_clause', 'children': ['76', '90']}; {'id': '76', 'type': 'boolean_operator', 'children': ['77', '80'], 'value': 'and'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '_queued_hotkey'}; {'id': '80', 'type': 'call', 'children': ['81', '86']}; {'id': '81', 'type': 'attribute', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'hotkey'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_queued_hotkey'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '98'], 'value': '*'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'green'}; {'id': '98', 'type': 'float', 'children': [], 'value': '0.75'}; {'id': '99', 'type': 'elif_clause', 'children': ['100', '105']}; {'id': '100', 'type': 'comparison_operator', 'children': ['101', '104'], 'value': 'in'}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'ability_id'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'past_abilities'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'red'}; {'id': '112', 'type': 'else_clause', 'children': ['113']}; {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'yellow'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'hotkey'}; {'id': '123', 'type': 'subscript', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'hotkey'}; {'id': '127', 'type': 'slice', 'children': ['128', '129', '130']}; {'id': '128', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '129', 'type': 'colon', 'children': []}; {'id': '130', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'surf'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'write_screen'}; {'id': '136', 'type': 'argument_list', 'children': ['137', '140', '141', '144']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': '_font_large'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '141', 'type': 'tuple', 'children': ['142', '143']}; {'id': '142', 'type': 'float', 'children': [], 'value': '0.2'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'hotkey'}; {'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': 'surf'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'write_screen'}; {'id': '150', 'type': 'argument_list', 'children': ['151', '154', '155', '158']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': '_font_large'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '155', 'type': 'tuple', 'children': ['156', '157']}; {'id': '156', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Draw the list of available commands.
|
def _update_clipper(self):
if self.clip_children and self._clipper is None:
self._clipper = Clipper()
elif not self.clip_children:
self._clipper = None
if self._clipper is None:
return
self._clipper.rect = self.inner_rect
self._clipper.transform = self.get_transform('framebuffer', 'visual')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_clipper'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '37', '45', '55']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16', '25']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '11'], 'value': 'and'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'clip_children'}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '15'], 'value': 'is'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_clipper'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_clipper'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Clipper'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'elif_clause', 'children': ['26', '30']}; {'id': '26', 'type': 'not_operator', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'clip_children'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_clipper'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'if_statement', 'children': ['38', '43']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '42'], 'value': 'is'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_clipper'}; {'id': '42', 'type': 'None', 'children': []}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'return_statement', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_clipper'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'rect'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'inner_rect'}; {'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': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_clipper'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'transform'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'get_transform'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'framebuffer'"}; {'id': '68', 'type': 'string', 'children': [], 'value': "'visual'"}
|
Called whenever the clipper for this widget may need to be updated.
|
def render_url(self):
url = self.url.format(**self.replacements)
if self.params:
return url + '?' + urlencode(self.params)
return url
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_url'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '36']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '9', 'type': 'call', 'children': ['10', '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': 'url'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'dictionary_splat', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'replacements'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '30'], 'value': '+'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '+'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'?'"}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'urlencode'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'url'}
|
Render the final URL based on available variables
|
def add_bgp_error_metadata(code, sub_code, def_desc='unknown'):
if _EXCEPTION_REGISTRY.get((code, sub_code)) is not None:
raise ValueError('BGPSException with code %d and sub-code %d '
'already defined.' % (code, sub_code))
def decorator(subclass):
if issubclass(subclass, BGPSException):
_EXCEPTION_REGISTRY[(code, sub_code)] = subclass
subclass.CODE = code
subclass.SUB_CODE = sub_code
subclass.DEF_DESC = def_desc
return subclass
return decorator
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_bgp_error_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sub_code'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'def_desc'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'unknown'"}; {'id': '9', 'type': 'block', 'children': ['10', '33', '73']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '21']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '20'], 'value': 'is not'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_EXCEPTION_REGISTRY'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'tuple', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sub_code'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '30'], 'value': '%'}; {'id': '27', 'type': 'concatenated_string', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'BGPSException with code %d and sub-code %d '"}; {'id': '29', 'type': 'string', 'children': [], 'value': "'already defined.'"}; {'id': '30', 'type': 'tuple', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sub_code'}; {'id': '33', 'type': 'function_definition', 'children': ['34', '35', '37']}; {'id': '34', 'type': 'function_name', 'children': [], 'value': 'decorator'}; {'id': '35', 'type': 'parameters', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'subclass'}; {'id': '37', 'type': 'block', 'children': ['38', '71']}; {'id': '38', 'type': 'if_statement', 'children': ['39', '44']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'issubclass'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'subclass'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'BGPSException'}; {'id': '44', 'type': 'block', 'children': ['45', '53', '59', '65']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '52']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_EXCEPTION_REGISTRY'}; {'id': '49', 'type': 'tuple', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sub_code'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'subclass'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'subclass'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'CODE'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'subclass'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'SUB_CODE'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'sub_code'}; {'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': 'subclass'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'DEF_DESC'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'def_desc'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'subclass'}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'decorator'}
|
Decorator for all exceptions that want to set exception class meta-data.
|
def _combined_wildcards_iter(flatterm: Iterator[TermAtom]) -> Iterator[TermAtom]:
last_wildcard = None
for term in flatterm:
if isinstance(term, Wildcard) and not isinstance(term, SymbolWildcard):
if last_wildcard is not None:
new_min_count = last_wildcard.min_count + term.min_count
new_fixed_size = last_wildcard.fixed_size and term.fixed_size
last_wildcard = Wildcard(new_min_count, new_fixed_size)
else:
last_wildcard = Wildcard(term.min_count, term.fixed_size)
else:
if last_wildcard is not None:
yield last_wildcard
last_wildcard = None
yield term
if last_wildcard is not None:
yield last_wildcard
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_combined_wildcards_iter'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'flatterm'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Iterator'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'TermAtom'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'generic_type', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Iterator'}; {'id': '15', 'type': 'type_parameter', 'children': ['16']}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'TermAtom'}; {'id': '18', 'type': 'block', 'children': ['19', '23', '105']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'flatterm'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'if_statement', 'children': ['28', '40', '88']}; {'id': '28', 'type': 'boolean_operator', 'children': ['29', '34'], 'value': 'and'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Wildcard'}; {'id': '34', 'type': 'not_operator', 'children': ['35']}; {'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': 'term'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'SymbolWildcard'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '45', '74']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'is not'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'block', 'children': ['46', '56', '66']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'new_min_count'}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '53'], 'value': '+'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'min_count'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'min_count'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'new_fixed_size'}; {'id': '59', 'type': 'boolean_operator', 'children': ['60', '63'], 'value': 'and'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'fixed_size'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'fixed_size'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'Wildcard'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'new_min_count'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'new_fixed_size'}; {'id': '74', 'type': 'else_clause', 'children': ['75']}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'Wildcard'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'min_count'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'fixed_size'}; {'id': '88', 'type': 'else_clause', 'children': ['89']}; {'id': '89', 'type': 'block', 'children': ['90', '102']}; {'id': '90', 'type': 'if_statement', 'children': ['91', '94']}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': 'is not'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '93', 'type': 'None', 'children': []}; {'id': '94', 'type': 'block', 'children': ['95', '98']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'yield', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '101', 'type': 'None', 'children': []}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'yield', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '109']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': 'is not'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}; {'id': '108', 'type': 'None', 'children': []}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'yield', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'last_wildcard'}
|
Combine consecutive wildcards in a flatterm into a single one.
|
def ConsultarTipoRetencion(self, sep="||"):
"Consulta de tipos de Retenciones."
ret = self.client.tipoRetencionConsultar(
auth={
'token': self.Token, 'sign': self.Sign,
'cuit': self.Cuit, },
)['tipoRetencionReturn']
self.__analizar_errores(ret)
array = ret.get('tiposRetencion', [])
return [("%s %%s %s %%s %s" % (sep, sep, sep)) %
(it['codigoDescripcion']['codigo'],
it['codigoDescripcion']['descripcion'])
for it in array]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ConsultarTipoRetencion'}; {'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': 'sep'}; {'id': '7', 'type': 'string', 'children': [], 'value': '"||"'}; {'id': '8', 'type': 'block', 'children': ['9', '11', '41', '48', '58']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"Consulta de tipos de Retenciones."'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '14', 'type': 'subscript', 'children': ['15', '40']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'tipoRetencionConsultar'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '24', 'type': 'dictionary', 'children': ['25', '30', '35']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'token'"}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Token'}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'sign'"}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'Sign'}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'cuit'"}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Cuit'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'tipoRetencionReturn'"}; {'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': '__analizar_errores'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'tiposRetencion'"}; {'id': '57', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'list_comprehension', 'children': ['60', '79']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '68'], 'value': '%'}; {'id': '61', 'type': '()', 'children': ['62']}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '%'}; {'id': '63', 'type': 'string', 'children': [], 'value': '"%s %%s %s %%s %s"'}; {'id': '64', 'type': 'tuple', 'children': ['65', '66', '67']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '68', 'type': 'tuple', 'children': ['69', '74']}; {'id': '69', 'type': 'subscript', 'children': ['70', '73']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'codigoDescripcion'"}; {'id': '73', 'type': 'string', 'children': [], 'value': "'codigo'"}; {'id': '74', 'type': 'subscript', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'codigoDescripcion'"}; {'id': '78', 'type': 'string', 'children': [], 'value': "'descripcion'"}; {'id': '79', 'type': 'for_in_clause', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'array'}
|
Consulta de tipos de Retenciones.
|
def add_package(self, check_name, package):
self._package_set.add(package)
package_data = self._packages[package.name]
self._checks_deps[check_name].append(package)
if package.version:
versions = package_data['versions']
versions[package.version].append(check_name)
if package.marker:
markers = package_data['markers']
markers[package.marker].append(check_name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_package'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'check_name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '27', '38', '60']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'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': '_package_set'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'package_data'}; {'id': '20', 'type': 'subscript', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_packages'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '36']}; {'id': '29', 'type': 'attribute', 'children': ['30', '35']}; {'id': '30', 'type': 'subscript', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_checks_deps'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'check_name'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '42', 'type': 'block', 'children': ['43', '49']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'versions'}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'package_data'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'versions'"}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '58']}; {'id': '51', 'type': 'attribute', 'children': ['52', '57']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'versions'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'check_name'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'marker'}; {'id': '64', 'type': 'block', 'children': ['65', '71']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'markers'}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'package_data'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'markers'"}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '80']}; {'id': '73', 'type': 'attribute', 'children': ['74', '79']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'markers'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'marker'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'check_name'}
|
Add a Package to the catalog for the given check
|
def _increment(self, n=1):
if self._cur_position >= self.num_tokens-1:
self._cur_positon = self.num_tokens - 1
self._finished = True
else:
self._cur_position += n
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_increment'}; {'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': 'n'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '19', '36']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '14'], 'value': '>='}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_cur_position'}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '18'], 'value': '-'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'num_tokens'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '19', 'type': 'block', 'children': ['20', '30']}; {'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': '_cur_positon'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '29'], 'value': '-'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'num_tokens'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_finished'}; {'id': '35', 'type': 'True', 'children': []}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'augmented_assignment', 'children': ['40', '43'], 'value': '+='}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_cur_position'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'n'}
|
Move forward n tokens in the stream.
|
def search_browser(self, text):
self.impl.get(self.base_url)
search_div = self.impl.find_element_by_id("search")
search_term = search_div.find_element_by_id("term")
search_term.send_keys(text)
search_div.find_element_by_id("submit").click()
e = self.impl.find_element_by_css_selector("table.list tr td a")
return e.get_attribute("href")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search_browser'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '29', '38', '45', '56', '67']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'impl'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'base_url'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'search_div'}; {'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': 'impl'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'find_element_by_id'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"search"'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'search_term'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'search_div'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'find_element_by_id'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"term"'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'search_term'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'send_keys'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '55']}; {'id': '47', 'type': 'attribute', 'children': ['48', '54']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'search_div'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'find_element_by_id'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"submit"'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'impl'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'find_element_by_css_selector'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': '"table.list tr td a"'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'get_attribute'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': '"href"'}
|
do a slow search via the website and return the first match
|
def pcap_name(self, devname):
try:
pcap_name = self.data[devname].pcap_name
except KeyError:
raise ValueError("Unknown network interface %r" % devname)
else:
return pcap_name
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pcap_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'devname'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '19', '29']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pcap_name'}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'subscript', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'devname'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pcap_name'}; {'id': '19', 'type': 'except_clause', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '28'], 'value': '%'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"Unknown network interface %r"'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'devname'}; {'id': '29', 'type': 'else_clause', 'children': ['30']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'pcap_name'}
|
Return pcap device name for given Windows device name.
|
def op_symbol(op_node):
ops = {
ast.UAdd: '+',
ast.USub: '-',
ast.Add: '+',
ast.Sub: '-',
ast.Mult: '*',
ast.Div: '/',
ast.Mod: '%',
ast.Eq: '=',
ast.NotEq: '!=',
ast.Lt: '<',
ast.LtE: '<=',
ast.Gt: '>',
ast.GtE: '>=',
}
if hasattr(ast, 'MatMult'):
ops[ast.MatMult] = '*'
return ops[op_node.__class__]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'op_symbol'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'op_node'}; {'id': '5', 'type': 'block', 'children': ['6', '75', '90']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '15', '20', '25', '30', '35', '40', '45', '50', '55', '60', '65', '70']}; {'id': '10', 'type': 'pair', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'UAdd'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'+'"}; {'id': '15', 'type': 'pair', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'USub'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '20', 'type': 'pair', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Add'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'+'"}; {'id': '25', 'type': 'pair', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Sub'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '30', 'type': 'pair', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Mult'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '35', 'type': 'pair', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Div'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '40', 'type': 'pair', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Mod'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'%'"}; {'id': '45', 'type': 'pair', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Eq'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '50', 'type': 'pair', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'NotEq'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'!='"}; {'id': '55', 'type': 'pair', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'Lt'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'<'"}; {'id': '60', 'type': 'pair', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'LtE'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'<='"}; {'id': '65', 'type': 'pair', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'Gt'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'>'"}; {'id': '70', 'type': 'pair', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'GtE'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'>='"}; {'id': '75', 'type': 'if_statement', 'children': ['76', '81']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'MatMult'"}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '89']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'MatMult'}; {'id': '89', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'op_node'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '__class__'}
|
Get the GLSL symbol for a Python operator.
|
def clear_caches(self):
for element_name in dir(self.components):
element = getattr(self.components, element_name)
if hasattr(element, 'cache_val'):
delattr(element, 'cache_val')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_caches'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '14']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'element_name'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'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': 'components'}; {'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': 'element'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'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': 'components'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'element_name'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '31']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'cache_val'"}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'delattr'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'cache_val'"}
|
Clears the Caches for all model elements
|
def revnet_base():
hparams = common_hparams.basic_params1()
hparams.add_hparam('num_channels', [64, 128, 256, 416])
hparams.add_hparam('num_layers_per_block', [1, 1, 10, 1])
hparams.add_hparam('bottleneck', True)
hparams.add_hparam('first_batch_norm', [False, True, True, True])
hparams.add_hparam('init_stride', 2)
hparams.add_hparam('init_kernel_size', 7)
hparams.add_hparam('init_maxpool', True)
hparams.add_hparam('strides', [1, 2, 2, 2])
hparams.add_hparam('num_channels_init_block', 64)
hparams.add_hparam('dim', '2d')
hparams.initializer = 'normal_unit_scaling'
hparams.initializer_gain = 2.
hparams.optimizer = 'Momentum'
hparams.optimizer_momentum_momentum = 0.9
hparams.optimizer_momentum_nesterov = True
hparams.weight_decay = 1e-4
hparams.clip_grad_norm = 0.0
hparams.learning_rate = 0.4
hparams.learning_rate_decay_scheme = 'cosine'
hparams.learning_rate_cosine_cycle_steps = 120000
hparams.batch_size = 128
return hparams
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'revnet_base'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '25', '37', '45', '57', '65', '73', '81', '93', '101', '109', '115', '121', '127', '133', '139', '145', '151', '157', '163', '169', '175']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'common_hparams'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'basic_params1'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'num_channels'"}; {'id': '20', 'type': 'list', 'children': ['21', '22', '23', '24'], 'value': '[64, 128, 256, 416]'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '64'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '128'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '416'}; {'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': 'hparams'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'num_layers_per_block'"}; {'id': '32', 'type': 'list', 'children': ['33', '34', '35', '36'], 'value': '[1, 1, 10, 1]'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'hparams'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'bottleneck'"}; {'id': '44', 'type': 'True', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'first_batch_norm'"}; {'id': '52', 'type': 'list', 'children': ['53', '54', '55', '56'], 'value': '[False, True, True, True]'}; {'id': '53', 'type': 'False', 'children': []}; {'id': '54', 'type': 'True', 'children': []}; {'id': '55', 'type': 'True', 'children': []}; {'id': '56', 'type': 'True', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'init_stride'"}; {'id': '64', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'string', 'children': [], 'value': "'init_kernel_size'"}; {'id': '72', 'type': 'integer', 'children': [], 'value': '7'}; {'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': 'hparams'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "'init_maxpool'"}; {'id': '80', 'type': 'True', 'children': []}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'string', 'children': [], 'value': "'strides'"}; {'id': '88', 'type': 'list', 'children': ['89', '90', '91', '92'], 'value': '[1, 2, 2, 2]'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '2'}; {'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': 'hparams'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'string', 'children': [], 'value': "'num_channels_init_block'"}; {'id': '100', 'type': 'integer', 'children': [], 'value': '64'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '106', 'type': 'argument_list', 'children': ['107', '108']}; {'id': '107', 'type': 'string', 'children': [], 'value': "'dim'"}; {'id': '108', 'type': 'string', 'children': [], 'value': "'2d'"}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'initializer'}; {'id': '114', 'type': 'string', 'children': [], 'value': "'normal_unit_scaling'"}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'initializer_gain'}; {'id': '120', 'type': 'float', 'children': [], 'value': '2.'}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'optimizer'}; {'id': '126', 'type': 'string', 'children': [], 'value': "'Momentum'"}; {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'optimizer_momentum_momentum'}; {'id': '132', 'type': 'float', 'children': [], 'value': '0.9'}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'optimizer_momentum_nesterov'}; {'id': '138', 'type': 'True', 'children': []}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'weight_decay'}; {'id': '144', 'type': 'float', 'children': [], 'value': '1e-4'}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'clip_grad_norm'}; {'id': '150', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'learning_rate'}; {'id': '156', 'type': 'float', 'children': [], 'value': '0.4'}; {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'assignment', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'learning_rate_decay_scheme'}; {'id': '162', 'type': 'string', 'children': [], 'value': "'cosine'"}; {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'assignment', 'children': ['165', '168']}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'learning_rate_cosine_cycle_steps'}; {'id': '168', 'type': 'integer', 'children': [], 'value': '120000'}; {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'assignment', 'children': ['171', '174']}; {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '174', 'type': 'integer', 'children': [], 'value': '128'}; {'id': '175', 'type': 'return_statement', 'children': ['176']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'hparams'}
|
Default hparams for Revnet.
|
def to_unix_ts(start_time):
if isinstance(start_time, datetime):
if is_timezone_aware(start_time):
start_time = start_time.astimezone(pytz.utc)
else:
log.warning(
"Non timezone-aware datetime object passed to IncrementalEndpoint. "
"The Zendesk API expects UTC time, if this is not the case results will be incorrect!"
)
unix_time = calendar.timegm(start_time.timetuple())
else:
unix_time = start_time
return int(unix_time)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_unix_ts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '5', 'type': 'block', 'children': ['6', '60']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '54']}; {'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': 'start_time'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '12', 'type': 'block', 'children': ['13', '41']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '18', '30']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'is_timezone_aware'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'astimezone'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pytz'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'utc'}; {'id': '30', 'type': 'else_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'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': 'log'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'concatenated_string', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"Non timezone-aware datetime object passed to IncrementalEndpoint. "'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"The Zendesk API expects UTC time, if this is not the case results will be incorrect!"'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'unix_time'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'calendar'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'timegm'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'timetuple'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'else_clause', 'children': ['55']}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'unix_time'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'unix_time'}
|
Given a datetime object, returns its value as a unix timestamp
|
def setOutputObject(self, newOutput=output.CalcpkgOutput(True, True)):
self.output = newOutput
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setOutputObject'}; {'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': 'newOutput'}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'CalcpkgOutput'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'True', 'children': []}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'newOutput'}
|
Set an object where all output from calcpkg will be redirected to for this repository
|
def print_region_quota(access_token, sub_id, region):
print(region + ':')
quota = azurerm.get_compute_usage(access_token, sub_id, region)
if SUMMARY is False:
print(json.dumps(quota, sort_keys=False, indent=2, separators=(',', ': ')))
try:
for resource in quota['value']:
if resource['name']['value'] == 'cores':
print(' Current: ' + str(resource['currentValue']) + ', limit: '
+ str(resource['limit']))
break
except KeyError:
print('Invalid data for region: ' + region)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_region_quota'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'access_token'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sub_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '26', '52']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '14'], 'value': '+'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '14', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'quota'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'azurerm'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_compute_usage'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'access_token'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sub_id'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'SUMMARY'}; {'id': '29', 'type': 'False', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41', '44', '47']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'quota'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sort_keys'}; {'id': '43', 'type': 'False', 'children': []}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'separators'}; {'id': '49', 'type': 'tuple', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "','"}; {'id': '51', 'type': 'string', 'children': [], 'value': "': '"}; {'id': '52', 'type': 'try_statement', 'children': ['53', '91']}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'for_statement', 'children': ['55', '56', '59']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'quota'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'if_statement', 'children': ['61', '68']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '67'], 'value': '=='}; {'id': '62', 'type': 'subscript', 'children': ['63', '66']}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '66', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '67', 'type': 'string', 'children': [], 'value': "'cores'"}; {'id': '68', 'type': 'block', 'children': ['69', '90']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '84'], 'value': '+'}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '83'], 'value': '+'}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '+'}; {'id': '76', 'type': 'string', 'children': [], 'value': "' Current: '"}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'currentValue'"}; {'id': '83', 'type': 'string', 'children': [], 'value': "', limit: '"}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '89', 'type': 'string', 'children': [], 'value': "'limit'"}; {'id': '90', 'type': 'break_statement', 'children': []}; {'id': '91', 'type': 'except_clause', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'binary_operator', 'children': ['99', '100'], 'value': '+'}; {'id': '99', 'type': 'string', 'children': [], 'value': "'Invalid data for region: '"}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'region'}
|
Print the Compute usage quota for a specific region
|
def get(self, namespace, key):
cfg = self.dbconfig.get(key, namespace, as_object=True)
return self.make_response({
'message': None,
'config': cfg
})
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '7', 'type': 'block', 'children': ['8', '23']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'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': 'dbconfig'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'as_object'}; {'id': '22', 'type': 'True', 'children': []}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'make_response'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'dictionary', 'children': ['30', '33']}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'message'"}; {'id': '32', 'type': 'None', 'children': []}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'config'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cfg'}
|
Get a specific configuration item
|
def onchain_exchange(self, withdraw_crypto, withdraw_address, value, unit='satoshi'):
self.onchain_rate = get_onchain_exchange_rates(
self.crypto, withdraw_crypto, best=True, verbose=self.verbose
)
exchange_rate = float(self.onchain_rate['rate'])
result = self.onchain_rate['service'].get_onchain_exchange_address(
self.crypto, withdraw_crypto, withdraw_address
)
address = result['deposit']
value_satoshi = self.from_unit_to_satoshi(value, unit)
if self.verbose:
print("Adding output of: %s satoshi (%.8f) via onchain exchange, converting to %s %s" % (
value_satoshi, (value_satoshi / 1e8),
exchange_rate * value_satoshi / 1e8, withdraw_crypto.upper()
))
self.outs.append({
'address': address,
'value': value_satoshi
})
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'onchain_exchange'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'withdraw_crypto'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'withdraw_address'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'satoshi'"}; {'id': '11', 'type': 'block', 'children': ['12', '32', '43', '60', '66', '76', '103']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'onchain_rate'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_onchain_exchange_rates'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23', '24', '27']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'crypto'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'withdraw_crypto'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'best'}; {'id': '26', 'type': 'True', 'children': []}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'exchange_rate'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'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': 'onchain_rate'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'rate'"}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '46', 'type': 'call', 'children': ['47', '54']}; {'id': '47', 'type': 'attribute', 'children': ['48', '53']}; {'id': '48', 'type': 'subscript', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'onchain_rate'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'service'"}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'get_onchain_exchange_address'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '58', '59']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'crypto'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'withdraw_crypto'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'withdraw_address'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'deposit'"}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'value_satoshi'}; {'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': 'from_unit_to_satoshi'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '76', 'type': 'if_statement', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '%'}; {'id': '86', 'type': 'string', 'children': [], 'value': '"Adding output of: %s satoshi (%.8f) via onchain exchange, converting to %s %s"'}; {'id': '87', 'type': 'tuple', 'children': ['88', '89', '93', '98']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'value_satoshi'}; {'id': '89', 'type': '()', 'children': ['90']}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '92'], 'value': '/'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'value_satoshi'}; {'id': '92', 'type': 'float', 'children': [], 'value': '1e8'}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '97'], 'value': '/'}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '96'], 'value': '*'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'exchange_rate'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'value_satoshi'}; {'id': '97', 'type': 'float', 'children': [], 'value': '1e8'}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'withdraw_crypto'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '102', 'type': 'argument_list', 'children': []}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '110']}; {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'outs'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'dictionary', 'children': ['112', '115']}; {'id': '112', 'type': 'pair', 'children': ['113', '114']}; {'id': '113', 'type': 'string', 'children': [], 'value': "'address'"}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '115', 'type': 'pair', 'children': ['116', '117']}; {'id': '116', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'value_satoshi'}
|
This method is like `add_output` but it sends to another
|
def spec(self):
from ambry_sources.sources import SourceSpec
d = self.dict
d['url'] = self.url
return SourceSpec(**d)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spec'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '26']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'dotted_name', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ambry_sources'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'SourceSpec'}; {'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': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'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': "'url'"}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'SourceSpec'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'dictionary_splat', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'd'}
|
Return a SourceSpec to describe this source
|
def bethe_fermi(energy, quasipart, shift, hopping, beta):
return fermi_dist(quasipart * energy - shift, beta) \
* bethe_lattice(energy, hopping)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bethe_fermi'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'energy'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'quasipart'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'shift'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'hopping'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'beta'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '21', '22'], 'value': '*'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'fermi_dist'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '20']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '19'], 'value': '-'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '*'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'quasipart'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'energy'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'shift'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'beta'}; {'id': '21', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'bethe_lattice'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'energy'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'hopping'}
|
product of the bethe lattice dos, fermi distribution
|
def _get_gcloud_sdk_credentials():
from google.auth import _cloud_sdk
credentials_filename = (
_cloud_sdk.get_application_default_credentials_path())
if not os.path.isfile(credentials_filename):
return None, None
credentials, project_id = _load_credentials_from_file(
credentials_filename)
if not project_id:
project_id = _cloud_sdk.get_project_id()
return credentials, project_id
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_gcloud_sdk_credentials'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '20', '35', '44', '56']}; {'id': '5', 'type': 'import_from_statement', 'children': ['6', '9']}; {'id': '6', 'type': 'dotted_name', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'google'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_cloud_sdk'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'credentials_filename'}; {'id': '14', 'type': '()', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_cloud_sdk'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_application_default_credentials_path'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'if_statement', 'children': ['21', '30']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'credentials_filename'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'expression_list', 'children': ['33', '34']}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'pattern_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_load_credentials_from_file'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'credentials_filename'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '47']}; {'id': '45', 'type': 'not_operator', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '_cloud_sdk'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get_project_id'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'expression_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'project_id'}
|
Gets the credentials and project ID from the Cloud SDK.
|
def _postprocess(valuestr):
intpattern = re.compile(r'^\-?\d+$')
floatpattern = re.compile(r'^\-?\d+\.\d+(E[+-]?\d\d+)?$')
datedtpattern = '%Y-%m-%d'
datedttimepattern = '%Y-%m-%dT%H:%M:%SZ'
timedtpattern = '%H:%M:%S.%f'
timepattern = re.compile(r'^\d{2}:\d{2}:\d{2}(\.\d{6})?')
if valuestr.startswith('"') and valuestr.endswith('"'):
return valuestr[1:-1]
elif re.match(intpattern, valuestr):
return int(valuestr)
elif re.match(floatpattern, valuestr):
return float(valuestr)
try:
return datetime.datetime.strptime(valuestr, datedtpattern).date()
except ValueError:
pass
try:
return datetime.datetime.strptime(valuestr, datedttimepattern)
except ValueError:
pass
mat = re.match(timepattern, valuestr)
if mat:
test = mat.group(0)
try:
return datetime.datetime.strptime(test, timedtpattern).time()
except ValueError:
pass
logging.info(
"The value %s couldn't be parsed as " % valuestr
+ "int, float, date, time, datetime. Returning it as string.")
return valuestr
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_postprocess'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '24', '28', '32', '36', '45', '96', '116', '132', '142', '174', '185']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'intpattern'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "r'^\\-?\\d+$'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'floatpattern'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': "r'^\\-?\\d+\\.\\d+(E[+-]?\\d\\d+)?$'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'datedtpattern'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'%Y-%m-%d'"}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'datedttimepattern'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'%Y-%m-%dT%H:%M:%SZ'"}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'timedtpattern'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'%H:%M:%S.%f'"}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'timepattern'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': "r'^\\d{2}:\\d{2}:\\d{2}(\\.\\d{6})?'"}; {'id': '45', 'type': 'if_statement', 'children': ['46', '59', '68', '82']}; {'id': '46', 'type': 'boolean_operator', 'children': ['47', '53'], 'value': 'and'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': '\'"\''}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'string', 'children': [], 'value': '\'"\''}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '63', 'type': 'slice', 'children': ['64', '65', '66']}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'colon', 'children': []}; {'id': '66', 'type': 'unary_operator', 'children': ['67'], 'value': '-'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'elif_clause', 'children': ['69', '76']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'intpattern'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '82', 'type': 'elif_clause', 'children': ['83', '90']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'floatpattern'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '96', 'type': 'try_statement', 'children': ['97', '112']}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '111']}; {'id': '100', 'type': 'attribute', 'children': ['101', '110']}; {'id': '101', 'type': 'call', 'children': ['102', '107']}; {'id': '102', 'type': 'attribute', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'strptime'}; {'id': '107', 'type': 'argument_list', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'datedtpattern'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '111', 'type': 'argument_list', 'children': []}; {'id': '112', 'type': 'except_clause', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'pass_statement', 'children': []}; {'id': '116', 'type': 'try_statement', 'children': ['117', '128']}; {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'return_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': 'datetime'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'strptime'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'datedttimepattern'}; {'id': '128', 'type': 'except_clause', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '130', 'type': 'block', 'children': ['131']}; {'id': '131', 'type': 'pass_statement', 'children': []}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'mat'}; {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'timepattern'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '142', 'type': 'if_statement', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'mat'}; {'id': '144', 'type': 'block', 'children': ['145', '154']}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '148', 'type': 'call', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'mat'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}; {'id': '153', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '154', 'type': 'try_statement', 'children': ['155', '170']}; {'id': '155', 'type': 'block', 'children': ['156']}; {'id': '156', 'type': 'return_statement', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '169']}; {'id': '158', 'type': 'attribute', 'children': ['159', '168']}; {'id': '159', 'type': 'call', 'children': ['160', '165']}; {'id': '160', 'type': 'attribute', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'strptime'}; {'id': '165', 'type': 'argument_list', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'timedtpattern'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '169', 'type': 'argument_list', 'children': []}; {'id': '170', 'type': 'except_clause', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '172', 'type': 'block', 'children': ['173']}; {'id': '173', 'type': 'pass_statement', 'children': []}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}; {'id': '175', 'type': 'call', 'children': ['176', '179']}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '179', 'type': 'argument_list', 'children': ['180']}; {'id': '180', 'type': 'binary_operator', 'children': ['181', '184'], 'value': '+'}; {'id': '181', 'type': 'binary_operator', 'children': ['182', '183'], 'value': '%'}; {'id': '182', 'type': 'string', 'children': [], 'value': '"The value %s couldn\'t be parsed as "'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'valuestr'}; {'id': '184', 'type': 'string', 'children': [], 'value': '"int, float, date, time, datetime. Returning it as string."'}; {'id': '185', 'type': 'return_statement', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'valuestr'}
|
Takes value as str, returns str, int, float, date, datetime, or time
|
def _get_metadata(self):
self.metadata = self.fetch_header()
self.variables = {g.name for g in self.metadata.grids}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'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': 'fetch_header'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '21', 'type': 'set_comprehension', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'grids'}
|
Get header information and store as metadata for the endpoint.
|
def read(self, _file):
with open(_file) as fh:
data = fh.read()
if self.verbose:
sys.stdout.write("read %d bytes from %s\n"
% (fh.tell(), _file))
return data
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': '_file'}; {'id': '6', 'type': 'block', 'children': ['7', '48']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'as_pattern', 'children': ['11', '15']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_file'}; {'id': '15', 'type': 'as_pattern_target', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '17', 'type': 'block', 'children': ['18', '26']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '%'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"read %d bytes from %s\\n"'}; {'id': '41', 'type': 'tuple', 'children': ['42', '47']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'tell'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_file'}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'data'}
|
return local file contents as endpoint.
|
def start_logger(self):
level = self.real_level(self.level)
logging.basicConfig(level=level)
self.set_logger(self.name, self.level)
config.dictConfig(self.config)
self.logger = logging.getLogger(self.name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start_logger'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '26', '38', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'real_level'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'basicConfig'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'set_logger'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'dictConfig'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'getLogger'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Enables the root logger and configures extra loggers.
|
def _approximate_unkown_bond_lengths(self):
dataset = self.lengths[BOND_SINGLE]
for n1 in periodic.iter_numbers():
for n2 in periodic.iter_numbers():
if n1 <= n2:
pair = frozenset([n1, n2])
atom1 = periodic[n1]
atom2 = periodic[n2]
if (pair not in dataset) and (atom1.covalent_radius is not None) and (atom2.covalent_radius is not None):
dataset[pair] = (atom1.covalent_radius + atom2.covalent_radius)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_approximate_unkown_bond_lengths'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '9', 'type': 'subscript', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'lengths'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'BOND_SINGLE'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'n1'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'periodic'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'iter_numbers'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '29']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'n2'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'periodic'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'iter_numbers'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '34']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': '<='}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'n1'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'n2'}; {'id': '34', 'type': 'block', 'children': ['35', '44', '50', '56']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'frozenset'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'list', 'children': ['42', '43'], 'value': '[n1, n2]'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'n1'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'n2'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'atom1'}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'periodic'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'n1'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'atom2'}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'periodic'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'n2'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '75']}; {'id': '57', 'type': 'boolean_operator', 'children': ['58', '69'], 'value': 'and'}; {'id': '58', 'type': 'boolean_operator', 'children': ['59', '63'], 'value': 'and'}; {'id': '59', 'type': '()', 'children': ['60']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': 'not in'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '63', 'type': '()', 'children': ['64']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '68'], 'value': 'is not'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'atom1'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'covalent_radius'}; {'id': '68', 'type': 'None', 'children': []}; {'id': '69', 'type': '()', 'children': ['70']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '74'], 'value': 'is not'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'atom2'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'covalent_radius'}; {'id': '74', 'type': 'None', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '81', 'type': '()', 'children': ['82']}; {'id': '82', 'type': 'binary_operator', 'children': ['83', '86'], 'value': '+'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'atom1'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'covalent_radius'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'atom2'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'covalent_radius'}
|
Completes the bond length database with approximations based on VDW radii
|
def status(self):
return self.repository._repo.status(self._ctx.p1().node(),
self._ctx.node())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'status'}; {'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', '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': 'repository'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_repo'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '27']}; {'id': '16', 'type': 'call', 'children': ['17', '26']}; {'id': '17', 'type': 'attribute', 'children': ['18', '25']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_ctx'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'p1'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_ctx'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '33', 'type': 'argument_list', 'children': []}
|
Returns modified, added, removed, deleted files for current changeset
|
def escape(self):
self.obj = self.obj.replace("&", self._html_escape_table["&"])
for i, k in enumerate(self._html_escape_table):
v = self._html_escape_table[k]
if k is not "&":
self.obj = self.obj.replace(k, v)
return self._wrap(self.obj)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'escape'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '62']}; {'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': 'obj'}; {'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': 'obj'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"&"'}; {'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': '_html_escape_table'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"&"'}; {'id': '24', 'type': 'for_statement', 'children': ['25', '28', '34']}; {'id': '25', 'type': 'pattern_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_html_escape_table'}; {'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': 'v'}; {'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': '_html_escape_table'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '43', 'type': 'if_statement', 'children': ['44', '47']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'is not'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"&"'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_wrap'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'obj'}
|
Escape a string for HTML interpolation.
|
def write_long(self, n, pack=Struct('>I').pack):
if 0 <= n <= 0xFFFFFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError('Long %d out of range 0..0xFFFFFFFF', n)
return self
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_long'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '8', 'type': 'attribute', 'children': ['9', '13']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Struct'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'>I'"}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '14', 'type': 'block', 'children': ['15', '41']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '20', '33']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18', '19'], 'value': '<='}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '0xFFFFFFFF'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_output_buffer'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '33', 'type': 'else_clause', 'children': ['34']}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'raise_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'Long %d out of range 0..0xFFFFFFFF'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}
|
Write an integer as an unsigned 32-bit value.
|
def _get_default_annual_spacing(nyears):
if nyears < 11:
(min_spacing, maj_spacing) = (1, 1)
elif nyears < 20:
(min_spacing, maj_spacing) = (1, 2)
elif nyears < 50:
(min_spacing, maj_spacing) = (1, 5)
elif nyears < 100:
(min_spacing, maj_spacing) = (5, 10)
elif nyears < 200:
(min_spacing, maj_spacing) = (5, 25)
elif nyears < 600:
(min_spacing, maj_spacing) = (10, 50)
else:
factor = nyears // 1000 + 1
(min_spacing, maj_spacing) = (factor * 20, factor * 100)
return (min_spacing, maj_spacing)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_default_annual_spacing'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '5', 'type': 'block', 'children': ['6', '106']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10', '19', '32', '45', '58', '71', '84']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9'], 'value': '<'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '9', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'tuple_pattern', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}; {'id': '16', 'type': 'tuple', 'children': ['17', '18']}; {'id': '17', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '19', 'type': 'elif_clause', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': '<'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'tuple_pattern', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}; {'id': '29', 'type': 'tuple', 'children': ['30', '31']}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '32', 'type': 'elif_clause', 'children': ['33', '36']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': '<'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '50'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '42']}; {'id': '39', 'type': 'tuple_pattern', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}; {'id': '42', 'type': 'tuple', 'children': ['43', '44']}; {'id': '43', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '45', 'type': 'elif_clause', 'children': ['46', '49']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': '<'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'tuple_pattern', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}; {'id': '55', 'type': 'tuple', 'children': ['56', '57']}; {'id': '56', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '58', 'type': 'elif_clause', 'children': ['59', '62']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': '<'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}; {'id': '65', 'type': 'tuple_pattern', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}; {'id': '68', 'type': 'tuple', 'children': ['69', '70']}; {'id': '69', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '25'}; {'id': '71', 'type': 'elif_clause', 'children': ['72', '75']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': '<'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '600'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'tuple_pattern', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}; {'id': '81', 'type': 'tuple', 'children': ['82', '83']}; {'id': '82', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '50'}; {'id': '84', 'type': 'else_clause', 'children': ['85']}; {'id': '85', 'type': 'block', 'children': ['86', '94']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'factor'}; {'id': '89', 'type': 'binary_operator', 'children': ['90', '93'], 'value': '+'}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '92'], 'value': '//'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'nyears'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '99']}; {'id': '96', 'type': 'tuple_pattern', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}; {'id': '99', 'type': 'tuple', 'children': ['100', '103']}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '*'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'factor'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '103', 'type': 'binary_operator', 'children': ['104', '105'], 'value': '*'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'factor'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'tuple', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'min_spacing'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'maj_spacing'}
|
Returns a default spacing between consecutive ticks for annual data.
|
def split_by_idx(self, valid_idx:Collection[int])->'ItemLists':
"Split the data according to the indexes in `valid_idx`."
train_idx = np.setdiff1d(arange_of(self.items), valid_idx)
return self.split_by_idxs(train_idx, valid_idx)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_by_idx'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'valid_idx'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'generic_type', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Collection'}; {'id': '10', 'type': 'type_parameter', 'children': ['11']}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'ItemLists'"}; {'id': '15', 'type': 'block', 'children': ['16', '18', '33']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"Split the data according to the indexes in `valid_idx`."'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'train_idx'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'setdiff1d'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '32']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'arange_of'}; {'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': 'items'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'valid_idx'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'split_by_idxs'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'train_idx'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'valid_idx'}
|
Split the data according to the indexes in `valid_idx`.
|
def as_dict(self):
attrs = vars(self)
return {key: attrs[key] for key in attrs if not key.startswith('_')}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'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': 'attrs'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'dictionary_comprehension', 'children': ['15', '20', '23']}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '20', 'type': 'for_in_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '23', 'type': 'if_clause', 'children': ['24']}; {'id': '24', 'type': 'not_operator', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'_'"}
|
Package up the public attributes as a dict.
|
def on_unicode_checkbox(self, w=None, state=False):
logging.debug("unicode State is %s", state)
self.controller.smooth_graph_mode = state
if state:
self.hline = urwid.AttrWrap(
urwid.SolidFill(u'\N{LOWER ONE QUARTER BLOCK}'), 'line')
else:
self.hline = urwid.AttrWrap(urwid.SolidFill(u' '), 'line')
for graph in self.graphs.values():
graph.set_smooth_colors(state)
self.show_graphs()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_unicode_checkbox'}; {'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': 'w'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '20', '28', '67', '84']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"unicode State is %s"'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', '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': 'controller'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'smooth_graph_mode'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30', '48']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'hline'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'urwid'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'AttrWrap'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '47']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'urwid'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'SolidFill'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "u'\\N{LOWER ONE QUARTER BLOCK}'"}; {'id': '47', 'type': 'string', 'children': [], 'value': "'line'"}; {'id': '48', 'type': 'else_clause', 'children': ['49']}; {'id': '49', 'type': 'block', 'children': ['50']}; {'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': 'hline'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'urwid'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'AttrWrap'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '66']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'urwid'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'SolidFill'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'string', 'children': [], 'value': "u' '"}; {'id': '66', 'type': 'string', 'children': [], 'value': "'line'"}; {'id': '67', 'type': 'for_statement', 'children': ['68', '69', '76']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'graph'}; {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'graphs'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'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': 'graph'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'set_smooth_colors'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'show_graphs'}; {'id': '89', 'type': 'argument_list', 'children': []}
|
Enable smooth edges if utf-8 is supported
|
def _get_num_interval(config, num_pre, num_post):
post = int(num_post) if num_post else 0
pre = int(num_pre) if num_pre is not None else _get_last_snapshot(config)['id']
return pre, post
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_num_interval'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'num_pre'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'num_post'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '35']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '11', 'type': 'conditional_expression', 'children': ['12', '16', '17'], 'value': 'if'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'num_post'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'num_post'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'pre'}; {'id': '21', 'type': 'conditional_expression', 'children': ['22', '26', '29'], 'value': 'if'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'num_pre'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is not'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'num_pre'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'subscript', 'children': ['30', '34']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_get_last_snapshot'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'expression_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'pre'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'post'}
|
Returns numerical interval based on optionals num_pre, num_post values
|
def create(
self, request, parent_lookup_seedteam=None,
parent_lookup_seedteam__organization=None):
team = self.check_team_permissions(
request, parent_lookup_seedteam,
parent_lookup_seedteam__organization)
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
permission = team.permissions.create(**serializer.validated_data)
serializer = self.get_serializer(instance=permission)
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'parent_lookup_seedteam'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'parent_lookup_seedteam__organization'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '24', '37', '46', '60', '71']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'team'}; {'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': 'check_team_permissions'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'parent_lookup_seedteam'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parent_lookup_seedteam__organization'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'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_serializer'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'data'}; {'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': 'serializer'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'raise_exception'}; {'id': '45', 'type': 'True', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'permission'}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'team'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'permissions'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'dictionary_splat', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'validated_data'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'get_serializer'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'permission'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'HTTP_201_CREATED'}
|
Add a permission to a team.
|
def _poll_trigger(self):
try:
os.write(self._poll_send, '\0'.encode('utf-8'))
except Exception as e:
log = self._getparam('log', self._discard)
log.debug("Ignoring self-pipe write error -- %s", e)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_poll_trigger'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '23']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_poll_send'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'\\0'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '23', 'type': 'except_clause', 'children': ['24', '28']}; {'id': '24', 'type': 'as_pattern', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '26', 'type': 'as_pattern_target', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '28', 'type': 'block', 'children': ['29', '41']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_getparam'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'log'"}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_discard'}; {'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': 'log'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"Ignoring self-pipe write error -- %s"'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'e'}
|
Trigger activity for the caller by writting a NUL to the self-pipe.
|
def as_dict(self):
dicts = [x.as_dict for x in self.children]
return {'{0} {1}'.format(self.name, self.value): dicts}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '18']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'dicts'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'as_dict'}; {'id': '13', 'type': 'for_in_clause', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'dictionary', 'children': ['20']}; {'id': '20', 'type': 'pair', 'children': ['21', '32']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'{0} {1}'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dicts'}
|
Return all child objects in nested dict.
|
def from_name(cls, name):
result = cls.list()
vlans = {}
for vlan in result:
vlans[vlan['name']] = vlan['id']
return vlans.get(name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '19', '33']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'vlans'}; {'id': '18', 'type': 'dictionary', 'children': []}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'vlan'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '30']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'vlans'}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'vlan'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'vlan'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'vlans'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Retrieve vlan id associated to a name.
|
def change_column_length(table: Table, column: Column, length: int, engine: Engine) -> None:
if column.type.length < length:
print("Changing length of {} from {} to {}".format(column, column.type.length, length))
column.type.length = length
column_name = column.name
column_type = column.type.compile(engine.dialect)
engine.execute('ALTER TABLE {table} ALTER COLUMN {column_name} TYPE {column_type}'.format(**locals()))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'change_column_length'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12', '16']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '12', 'type': 'typed_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '16', 'type': 'typed_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '18', 'type': 'type', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Engine'}; {'id': '20', 'type': 'type', 'children': ['21']}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '31']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '30'], 'value': '<'}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '31', 'type': 'block', 'children': ['32', '48', '56', '62', '75']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"Changing length of {} from {} to {}"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42', '47']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'column_type'}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'ALTER TABLE {table} ALTER COLUMN {column_name} TYPE {column_type}'"}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'dictionary_splat', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'locals'}; {'id': '89', 'type': 'argument_list', 'children': []}
|
Change the column length in the supplied table
|
def read_event(suppress=False):
queue = _queue.Queue(maxsize=1)
hooked = hook(queue.put, suppress=suppress)
while True:
event = queue.get()
unhook(hooked)
return event
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_event'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'suppress'}; {'id': '6', 'type': 'False', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '19', '31']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_queue'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Queue'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'maxsize'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'hooked'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'hook'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'suppress'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'suppress'}; {'id': '31', 'type': 'while_statement', 'children': ['32', '33']}; {'id': '32', 'type': 'True', 'children': []}; {'id': '33', 'type': 'block', 'children': ['34', '42', '47']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'unhook'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'hooked'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'event'}
|
Blocks until a keyboard event happens, then returns that event.
|
def fetch_deposits(self, limit: int) -> List[Deposit]:
return self._transactions(self._deposits, 'deposits', limit)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch_deposits'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'generic_type', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '12', 'type': 'type_parameter', 'children': ['13']}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Deposit'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_transactions'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '25', '26']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_deposits'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'deposits'"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'limit'}
|
Fetch latest deposits, must provide a limit.
|
def createNew(cls, store, pathSegments):
if isinstance(pathSegments, basestring):
raise ValueError(
'Received %r instead of a sequence' % (pathSegments,))
if store.dbdir is None:
self = cls(store=store, storepath=None)
else:
storepath = store.newDirectory(*pathSegments)
self = cls(store=store, storepath=storepath)
self.open()
self.close()
return self
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'createNew'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'pathSegments'}; {'id': '7', 'type': 'block', 'children': ['8', '23', '66', '72', '78']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pathSegments'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'basestring'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '%'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'Received %r instead of a sequence'"}; {'id': '21', 'type': 'tuple', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pathSegments'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '29', '42']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '28'], 'value': 'is'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dbdir'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '39']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'storepath'}; {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'else_clause', 'children': ['43']}; {'id': '43', 'type': 'block', 'children': ['44', '54']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'storepath'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'newDirectory'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'list_splat', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'pathSegments'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63']}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'storepath'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'storepath'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}
|
Create a new SubStore, allocating a new file space for it.
|
def rdf_source(self, aformat="turtle"):
if aformat and aformat not in self.SUPPORTED_FORMATS:
return "Sorry. Allowed formats are %s" % str(self.SUPPORTED_FORMATS)
if aformat == "dot":
return self.__serializedDot()
else:
return self.rdflib_graph.serialize(format=aformat)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rdf_source'}; {'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': 'aformat'}; {'id': '7', 'type': 'string', 'children': [], 'value': '"turtle"'}; {'id': '8', 'type': 'block', 'children': ['9', '27']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '17']}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '12'], 'value': 'and'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'aformat'}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'not in'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'aformat'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'SUPPORTED_FORMATS'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '%'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Sorry. Allowed formats are %s"'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'SUPPORTED_FORMATS'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '31', '38']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': '=='}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'aformat'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"dot"'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '__serializedDot'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'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': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'rdflib_graph'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'serialize'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'aformat'}
|
Serialize graph using the format required
|
def from_description(cls, description, attrs):
hash_key = None
range_key = None
index_type = description["Projection"]["ProjectionType"]
includes = description["Projection"].get("NonKeyAttributes")
for data in description["KeySchema"]:
name = data["AttributeName"]
if name not in attrs:
continue
key_type = data["KeyType"]
if key_type == "HASH":
hash_key = TableField(name, attrs[name].data_type, key_type)
elif key_type == "RANGE":
range_key = TableField(name, attrs[name].data_type, key_type)
throughput = description["ProvisionedThroughput"]
return cls(
description["IndexName"],
index_type,
description["IndexStatus"],
hash_key,
range_key,
throughput["ReadCapacityUnits"],
throughput["WriteCapacityUnits"],
description.get("IndexSizeBytes", 0),
includes,
description,
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_description'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '16', '24', '35', '95', '101']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'hash_key'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'range_key'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'index_type'}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"Projection"'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"ProjectionType"'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'includes'}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"Projection"'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"NonKeyAttributes"'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '40']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"KeySchema"'}; {'id': '40', 'type': 'block', 'children': ['41', '47', '53', '59']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"AttributeName"'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '51']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'not in'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'continue_statement', 'children': []}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"KeyType"'}; {'id': '59', 'type': 'if_statement', 'children': ['60', '63', '77']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': '=='}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"HASH"'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'hash_key'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'TableField'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71', '76']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '77', 'type': 'elif_clause', 'children': ['78', '81']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '80'], 'value': '=='}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '80', 'type': 'string', 'children': [], 'value': '"RANGE"'}; {'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_key'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'TableField'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89', '94']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '89', 'type': 'attribute', 'children': ['90', '93']}; {'id': '90', 'type': 'subscript', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'key_type'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'throughput'}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '100', 'type': 'string', 'children': [], 'value': '"ProvisionedThroughput"'}; {'id': '101', 'type': 'return_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '108', '109', '112', '113', '114', '117', '120', '127', '128']}; {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '107', 'type': 'string', 'children': [], 'value': '"IndexName"'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'index_type'}; {'id': '109', 'type': 'subscript', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '111', 'type': 'string', 'children': [], 'value': '"IndexStatus"'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'hash_key'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'range_key'}; {'id': '114', 'type': 'subscript', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'throughput'}; {'id': '116', 'type': 'string', 'children': [], 'value': '"ReadCapacityUnits"'}; {'id': '117', 'type': 'subscript', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'throughput'}; {'id': '119', 'type': 'string', 'children': [], 'value': '"WriteCapacityUnits"'}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '126']}; {'id': '125', 'type': 'string', 'children': [], 'value': '"IndexSizeBytes"'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'includes'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'description'}
|
Create an object from a dynamo3 response
|
def format_hsl(hsl_color):
hue, saturation, lightness = hsl_color
return 'hsl({}, {:.2%}, {:.2%})'.format(hue, saturation, lightness)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_hsl'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'hsl_color'}; {'id': '5', 'type': 'block', 'children': ['6', '13']}; {'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': 'hue'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'saturation'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'lightness'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'hsl_color'}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'hsl({}, {:.2%}, {:.2%})'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'hue'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'saturation'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'lightness'}
|
Format hsl color as css color string.
|
def toggle_value(request, name):
obj = service.system.namespace.get(name, None)
if not obj or service.read_only:
raise Http404
new_status = obj.status = not obj.status
if service.redirect_from_setters:
return HttpResponseRedirect(reverse('set_ready', args=(name, new_status)))
else:
return set_ready(request, name, new_status)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'toggle_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '31', '42']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '10', 'type': 'call', 'children': ['11', '18']}; {'id': '11', 'type': 'attribute', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'if_statement', 'children': ['22', '28']}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '25'], 'value': 'or'}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'read_only'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'raise_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Http404'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'new_status'}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '38', 'type': 'not_operator', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '46', '60']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'redirect_from_setters'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'HttpResponseRedirect'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'set_ready'"}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '57', 'type': 'tuple', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'new_status'}; {'id': '60', 'type': 'else_clause', 'children': ['61']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'set_ready'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'new_status'}
|
For manual shortcut links to perform toggle actions
|
def by_current_session(cls):
session = Session.current_session()
if session is None:
return None
return cls.where_id(session.user_id)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'by_current_session'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '21']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Session'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'current_session'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': 'is'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'where_id'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'user_id'}
|
Returns current user session
|
def disconnect(self):
for name, wire in self.wires():
self.cut(name, disconnect=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'disconnect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '15']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'wire'}; {'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': 'wires'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cut'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'disconnect'}; {'id': '25', 'type': 'True', 'children': []}
|
Cut all wires and disconnect all connections established on this link
|
def _walk(self, root_path='', root_id=''):
title = '%s._walk' % self.__class__.__name__
if root_id:
pass
elif root_path:
root_id, root_parent = self._get_id(root_path)
for file_id, name, mimetype in self._list_directory(root_id):
file_path = os.path.join(root_path, name)
if mimetype == 'application/vnd.google-apps.folder':
for path, id in self._walk(root_path=file_path, root_id=file_id):
yield path, id
else:
yield file_path, file_id
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_walk'}; {'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': 'root_path'}; {'id': '7', 'type': 'string', 'children': [], 'value': "''"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'root_id'}; {'id': '10', 'type': 'string', 'children': [], 'value': "''"}; {'id': '11', 'type': 'block', 'children': ['12', '22', '40']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '%'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'%s._walk'"}; {'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': '__class__'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '24', '26']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'root_id'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'pass_statement', 'children': []}; {'id': '26', 'type': 'elif_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'root_path'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'pattern_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'root_id'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'root_parent'}; {'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': '_get_id'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'root_path'}; {'id': '40', 'type': 'for_statement', 'children': ['41', '45', '51']}; {'id': '41', 'type': 'pattern_list', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'file_id'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'mimetype'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_list_directory'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'root_id'}; {'id': '51', 'type': 'block', 'children': ['52', '64']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'root_path'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '68', '90']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': '=='}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'mimetype'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'application/vnd.google-apps.folder'"}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'for_statement', 'children': ['70', '73', '84']}; {'id': '70', 'type': 'pattern_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_walk'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '81']}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'root_path'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'root_id'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'file_id'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'yield', 'children': ['87']}; {'id': '87', 'type': 'expression_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '90', 'type': 'else_clause', 'children': ['91']}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'yield', 'children': ['94']}; {'id': '94', 'type': 'expression_list', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'file_id'}
|
a generator method which walks the file structure of the dropbox collection
|
def _complete_exit(self, cmd, args, text):
if args:
return
return [ x for x in { 'root', 'all', } \
if x.startswith(text) ]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_complete_exit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '8', 'type': 'block', 'children': ['9', '13']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': []}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'list_comprehension', 'children': ['15', '16', '21', '22']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '16', 'type': 'for_in_clause', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '18', 'type': 'set', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'root'"}; {'id': '20', 'type': 'string', 'children': [], 'value': "'all'"}; {'id': '21', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '22', 'type': 'if_clause', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'text'}
|
Find candidates for the 'exit' command.
|
def numpyview(arr, datatype, shape, raw=False):
if raw:
return n.frombuffer(arr, dtype=n.dtype(datatype)).view(n.dtype(datatype)).reshape(shape)
else:
return n.frombuffer(arr.get_obj(), dtype=n.dtype(datatype)).view(n.dtype(datatype)).reshape(shape)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'numpyview'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '13', '44']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '42']}; {'id': '16', 'type': 'attribute', 'children': ['17', '41']}; {'id': '17', 'type': 'call', 'children': ['18', '34']}; {'id': '18', 'type': 'attribute', 'children': ['19', '33']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'frombuffer'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'reshape'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '78']}; {'id': '48', 'type': 'attribute', 'children': ['49', '77']}; {'id': '49', 'type': 'call', 'children': ['50', '70']}; {'id': '50', 'type': 'attribute', 'children': ['51', '69']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'frombuffer'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '61']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'get_obj'}; {'id': '60', 'type': 'argument_list', 'children': []}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'datatype'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'reshape'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'shape'}
|
Takes mp shared array and returns numpy array with given shape.
|
def main(ctx, opts, version):
if version:
print_version()
elif ctx.invoked_subcommand is None:
click.echo(ctx.get_help())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '10', '15']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'print_version'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'elif_clause', 'children': ['16', '21']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': 'is'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'invoked_subcommand'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get_help'}; {'id': '32', 'type': 'argument_list', 'children': []}
|
Handle entrypoint to CLI.
|
def __create_output_dir(base_dir):
root, tail = os.path.split(base_dir)
dir = None
if tail:
if base_dir.endswith('/'):
dir = base_dir
else:
dir = root
else:
if base_dir.endswith('/'):
dir = base_dir
if dir and not os.path.isdir(dir):
os.makedirs(dir)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__create_output_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '23', '58']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'tail'}; {'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': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'if_statement', 'children': ['24', '25', '44']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tail'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '33', '38']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'/'"}; {'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': 'dir'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'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': 'dir'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'if_statement', 'children': ['47', '53']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'base_dir'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '70']}; {'id': '59', 'type': 'boolean_operator', 'children': ['60', '61'], 'value': 'and'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '61', 'type': 'not_operator', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'dir'}
|
Ensure that the output directory base_dir exists.
|
def check_spinning_children(self):
child_jobs = self.task_master.get_child_work_units(self.worker_id)
now = time.time() + self.stop_jobs_early
for child, wul in child_jobs.iteritems():
if not isinstance(wul, (list, tuple)):
wul = [wul]
if not wul:
continue
wul = filter(lambda wu: wu.worker_id == child, wul)
if any(filter(lambda wu: wu.expires > now, wul)):
continue
environment = self.task_master.get_heartbeat(child)
if not environment:
continue
if 'pid' not in environment:
continue
if environment['pid'] not in self.children:
continue
os.kill(environment['pid'], signal.SIGTERM)
for wu in wul:
if wu.data is None:
logger.critical('how did wu.data become: %r' % wu.data)
else:
wu.data['traceback'] = 'job expired'
wu.fail(exc=Exception('job expired'))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_spinning_children'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '31']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'child_jobs'}; {'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': 'task_master'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_child_work_units'}; {'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': 'worker_id'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '28'], 'value': '+'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'stop_jobs_early'}; {'id': '31', 'type': 'for_statement', 'children': ['32', '35', '40']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'child_jobs'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41', '56', '61', '76', '94', '105', '110', '116', '126', '138']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '50']}; {'id': '42', 'type': 'not_operator', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '47', 'type': 'tuple', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '54', 'type': 'list', 'children': ['55'], 'value': '[wul]'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '59']}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'continue_statement', 'children': []}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '75']}; {'id': '67', 'type': 'lambda', 'children': ['68', '70']}; {'id': '68', 'type': 'lambda_parameters', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '74'], 'value': '=='}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'worker_id'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '76', 'type': 'if_statement', 'children': ['77', '92']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '91']}; {'id': '83', 'type': 'lambda', 'children': ['84', '86']}; {'id': '84', 'type': 'lambda_parameters', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '90'], 'value': '>'}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'expires'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'continue_statement', 'children': []}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '97', 'type': 'call', 'children': ['98', '103']}; {'id': '98', 'type': 'attribute', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'task_master'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'get_heartbeat'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '108']}; {'id': '106', 'type': 'not_operator', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '108', 'type': 'block', 'children': ['109']}; {'id': '109', 'type': 'continue_statement', 'children': []}; {'id': '110', 'type': 'if_statement', 'children': ['111', '114']}; {'id': '111', 'type': 'comparison_operator', 'children': ['112', '113'], 'value': 'not in'}; {'id': '112', 'type': 'string', 'children': [], 'value': "'pid'"}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'continue_statement', 'children': []}; {'id': '116', 'type': 'if_statement', 'children': ['117', '124']}; {'id': '117', 'type': 'comparison_operator', 'children': ['118', '121'], 'value': 'not in'}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '120', 'type': 'string', 'children': [], 'value': "'pid'"}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'continue_statement', 'children': []}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'kill'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '135']}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '134', 'type': 'string', 'children': [], 'value': "'pid'"}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'signal'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'SIGTERM'}; {'id': '138', 'type': 'for_statement', 'children': ['139', '140', '141']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'wul'}; {'id': '141', 'type': 'block', 'children': ['142', '170']}; {'id': '142', 'type': 'if_statement', 'children': ['143', '148', '160']}; {'id': '143', 'type': 'comparison_operator', 'children': ['144', '147'], 'value': 'is'}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '147', 'type': 'None', 'children': []}; {'id': '148', 'type': 'block', 'children': ['149']}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'call', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'critical'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'binary_operator', 'children': ['156', '157'], 'value': '%'}; {'id': '156', 'type': 'string', 'children': [], 'value': "'how did wu.data become: %r'"}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '160', 'type': 'else_clause', 'children': ['161']}; {'id': '161', 'type': 'block', 'children': ['162']}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}; {'id': '163', 'type': 'assignment', 'children': ['164', '169']}; {'id': '164', 'type': 'subscript', 'children': ['165', '168']}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '168', 'type': 'string', 'children': [], 'value': "'traceback'"}; {'id': '169', 'type': 'string', 'children': [], 'value': "'job expired'"}; {'id': '170', 'type': 'expression_statement', 'children': ['171']}; {'id': '171', 'type': 'call', 'children': ['172', '175']}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'wu'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'fail'}; {'id': '175', 'type': 'argument_list', 'children': ['176']}; {'id': '176', 'type': 'keyword_argument', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '178', 'type': 'call', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '180', 'type': 'argument_list', 'children': ['181']}; {'id': '181', 'type': 'string', 'children': [], 'value': "'job expired'"}
|
Stop children that are working on overdue jobs.
|
def vdp_vlan_change_cb(self, port_uuid, lvid, vdp_vlan, fail_reason):
LOG.info("Vlan change CB lvid %(lvid)s VDP %(vdp)s",
{'lvid': lvid, 'vdp': vdp_vlan})
self.update_vm_result(port_uuid, constants.RESULT_SUCCESS,
lvid=lvid, vdp_vlan=vdp_vlan,
fail_reason=fail_reason)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vdp_vlan_change_cb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'port_uuid'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lvid'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'vdp_vlan'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'fail_reason'}; {'id': '9', 'type': 'block', 'children': ['10', '24']}; {'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': 'LOG'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"Vlan change CB lvid %(lvid)s VDP %(vdp)s"'}; {'id': '17', 'type': 'dictionary', 'children': ['18', '21']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'lvid'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'lvid'}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'vdp'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'vdp_vlan'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'update_vm_result'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31', '34', '37', '40']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'port_uuid'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'constants'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'RESULT_SUCCESS'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'lvid'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'lvid'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'vdp_vlan'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'vdp_vlan'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fail_reason'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fail_reason'}
|
Callback function for updating the VDP VLAN in DB.
|
def write_batch_json(self, content):
timestamp = str(time.time()).replace('.', '')
batch_json_file = os.path.join(
self.tcex.args.tc_temp_path, 'batch-{}.json'.format(timestamp)
)
with open(batch_json_file, 'w') as fh:
json.dump(content, fh, indent=2)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_batch_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '6', 'type': 'block', 'children': ['7', '24', '47']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '10', 'type': 'call', 'children': ['11', '21']}; {'id': '11', 'type': 'attribute', 'children': ['12', '20']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "''"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'batch_json_file'}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '41']}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'tcex'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tc_temp_path'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'batch-{}.json'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '47', 'type': 'with_statement', 'children': ['48', '58']}; {'id': '48', 'type': 'with_clause', 'children': ['49']}; {'id': '49', 'type': 'with_item', 'children': ['50']}; {'id': '50', 'type': 'as_pattern', 'children': ['51', '56']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'batch_json_file'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '56', 'type': 'as_pattern_target', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66', '67']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '2'}
|
Write batch json data to a file.
|
def rd_files(self, study_fn, pop_fn):
study, pop = self._read_geneset(study_fn, pop_fn)
print("Study: {0} vs. Population {1}\n".format(len(study), len(pop)))
return study, pop
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rd_files'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'study_fn'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'pop_fn'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '37']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'study'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_read_geneset'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'study_fn'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pop_fn'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"Study: {0} vs. Population {1}\\n"'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '33']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'study'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'expression_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'study'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'pop'}
|
Read files and return study and population.
|
def journals(self):
try:
target = self._item_path
json_data = self._redmine.get(target % str(self.id),
parms={'include': 'journals'})
data = self._redmine.unwrap_json(None, json_data)
journals = [Journal(redmine=self._redmine,
data=journal,
type='issue_journal')
for journal in data['issue']['journals']]
return journals
except Exception:
return []
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'journals'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '77']}; {'id': '7', 'type': 'block', 'children': ['8', '14', '38', '50', '75']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_item_path'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'json_data'}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_redmine'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '32']}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '%'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'str'}; {'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': 'id'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'parms'}; {'id': '34', 'type': 'dictionary', 'children': ['35']}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'include'"}; {'id': '37', 'type': 'string', 'children': [], 'value': "'journals'"}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'data'}; {'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': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_redmine'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'unwrap_json'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'None', 'children': []}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'json_data'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'journals'}; {'id': '53', 'type': 'list_comprehension', 'children': ['54', '68']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'Journal'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '62', '65']}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'redmine'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': '_redmine'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'journal'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'issue_journal'"}; {'id': '68', 'type': 'for_in_clause', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'journal'}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '73', 'type': 'string', 'children': [], 'value': "'issue'"}; {'id': '74', 'type': 'string', 'children': [], 'value': "'journals'"}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'journals'}; {'id': '77', 'type': 'except_clause', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'list', 'children': [], 'value': '[]'}
|
Retrieve journals attribute for this very Issue
|
def _split_tidy(self, string, maxsplit=None):
if maxsplit is None:
return string.rstrip("\n").split("\t")
else:
return string.rstrip("\n").split("\t", maxsplit)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_split_tidy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'maxsplit'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14', '27']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'maxsplit'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '25']}; {'id': '17', 'type': 'attribute', 'children': ['18', '24']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"\\t"'}; {'id': '27', 'type': 'else_clause', 'children': ['28']}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '39']}; {'id': '31', 'type': 'attribute', 'children': ['32', '38']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': '"\\t"'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'maxsplit'}
|
Rstrips string for \n and splits string for \t
|
def allReadGroups(self):
for dataset in self.getDatasets():
for readGroupSet in dataset.getReadGroupSets():
for readGroup in readGroupSet.getReadGroups():
yield readGroup
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'allReadGroups'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '13']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'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': 'getDatasets'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'readGroupSet'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'getReadGroupSets'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '29']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'readGroup'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'readGroupSet'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'getReadGroups'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'yield', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'readGroup'}
|
Return an iterator over all read groups in the data repo
|
def load(self, value):
if self.property_type is None:
return value
elif not isinstance(self.property_type, BaseType):
raise TypeError('property_type must be schematics BaseType')
else:
native_value = self.property_type.to_native(value)
self.property_type.validate(native_value)
return native_value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '16', '31']}; {'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': 'property_type'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '16', 'type': 'elif_clause', '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', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'property_type'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'BaseType'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'property_type must be schematics BaseType'"}; {'id': '31', 'type': 'else_clause', 'children': ['32']}; {'id': '32', 'type': 'block', 'children': ['33', '44', '53']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'native_value'}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'property_type'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'to_native'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'property_type'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'validate'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'native_value'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'native_value'}
|
Load a value, converting it to the proper type if validation_type exists.
|
def current_index(self):
i = self._parent.proxy_model.mapToSource(self._parent.currentIndex())
return i
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'current_index'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '25']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_parent'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'proxy_model'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'mapToSource'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_parent'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'currentIndex'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'i'}
|
Get the currently selected index in the parent table view.
|
def console(cls, id):
oper = cls.call('paas.update', cls.usable_id(id), {'console': 1})
cls.echo('Activation of the console on your PaaS instance')
cls.display_progress(oper)
console_url = Paas.info(cls.usable_id(id))['console']
access = 'ssh %s' % console_url
cls.execute(access)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'console'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'block', 'children': ['7', '26', '33', '40', '56', '62']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'oper'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'call'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '22']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'paas.update'"}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'usable_id'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '22', 'type': 'dictionary', 'children': ['23']}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'console'"}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'Activation of the console on your PaaS instance'"}; {'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': 'cls'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'display_progress'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'oper'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'console_url'}; {'id': '43', 'type': 'subscript', 'children': ['44', '55']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Paas'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'usable_id'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'console'"}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'access'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '%'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'ssh %s'"}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'console_url'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'access'}
|
Open a console to a PaaS instance.
|
def union(*args):
if not args:
return []
base = args[0]
for other in args[1:]:
base.extend(other)
return list(OrderedDict.fromkeys(base))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'union'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '34']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '10']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '26']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '23', 'type': 'slice', 'children': ['24', '25']}; {'id': '24', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '25', 'type': 'colon', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27']}; {'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': 'base'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fromkeys'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'base'}
|
Return the union of lists, ordering by first seen in any list
|
def main(host, port, timeout, itimeout, qsize, backlog, maxtry, bsize, verbose, logfile=None, logcfgfile=None, cfgfile=None):
dict_cfg = {}
if cfgfile:
dict_cfg = app_config.get_config_by_file(cfgfile)
def get_param(key, param, default):
return param or dict_cfg.get(key, None) or default
cfg = app_config.Config(
address=(get_param("host", host, "localhost"), get_param("port", port, 3333)),
timeout=get_param("timeout", timeout, 10),
msg_size=get_param("bsize", bsize, 4096),
max_try_turn=get_param("maxtry", maxtry, 3),
backlog=get_param("backlog", backlog, 1024),
max_queue_size=get_param("qsize", qsize, 100),
endpoint_timeout=get_param("itimeout", itimeout, 60),
verbose=get_param("verbose", verbose, 0),
logfile=get_param("logfile", logfile, None),
logcfgfile=get_param("logcfgfile", logcfgfile, None)
)
click.echo("Starting sockspy...")
sockspy_main.run(cfg)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '16', '19']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'itimeout'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'qsize'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'backlog'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'maxtry'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'bsize'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'logcfgfile'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cfgfile'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23', '27', '39', '58', '153', '160']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dict_cfg'}; {'id': '26', 'type': 'dictionary', 'children': []}; {'id': '27', 'type': 'if_statement', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cfgfile'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dict_cfg'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'app_config'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'get_config_by_file'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cfgfile'}; {'id': '39', 'type': 'function_definition', 'children': ['40', '41', '45']}; {'id': '40', 'type': 'function_name', 'children': [], 'value': 'get_param'}; {'id': '41', 'type': 'parameters', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'boolean_operator', 'children': ['48', '57'], 'value': 'or'}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '50'], 'value': 'or'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dict_cfg'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '56', 'type': 'None', 'children': []}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'app_config'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'Config'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '81', '89', '97', '105', '113', '121', '129', '137', '145']}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '68', 'type': 'tuple', 'children': ['69', '75']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73', '74']}; {'id': '72', 'type': 'string', 'children': [], 'value': '"host"'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"localhost"'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79', '80']}; {'id': '78', 'type': 'string', 'children': [], 'value': '"port"'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '3333'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87', '88']}; {'id': '86', 'type': 'string', 'children': [], 'value': '"timeout"'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '89', 'type': 'keyword_argument', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'msg_size'}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95', '96']}; {'id': '94', 'type': 'string', 'children': [], 'value': '"bsize"'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'bsize'}; {'id': '96', 'type': 'integer', 'children': [], 'value': '4096'}; {'id': '97', 'type': 'keyword_argument', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'max_try_turn'}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103', '104']}; {'id': '102', 'type': 'string', 'children': [], 'value': '"maxtry"'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'maxtry'}; {'id': '104', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'backlog'}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111', '112']}; {'id': '110', 'type': 'string', 'children': [], 'value': '"backlog"'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'backlog'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '1024'}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'max_queue_size'}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '119', '120']}; {'id': '118', 'type': 'string', 'children': [], 'value': '"qsize"'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'qsize'}; {'id': '120', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '121', 'type': 'keyword_argument', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'endpoint_timeout'}; {'id': '123', 'type': 'call', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '127', '128']}; {'id': '126', 'type': 'string', 'children': [], 'value': '"itimeout"'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'itimeout'}; {'id': '128', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '129', 'type': 'keyword_argument', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '131', 'type': 'call', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '133', 'type': 'argument_list', 'children': ['134', '135', '136']}; {'id': '134', 'type': 'string', 'children': [], 'value': '"verbose"'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '136', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '137', 'type': 'keyword_argument', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '141', 'type': 'argument_list', 'children': ['142', '143', '144']}; {'id': '142', 'type': 'string', 'children': [], 'value': '"logfile"'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '144', 'type': 'None', 'children': []}; {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'logcfgfile'}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'get_param'}; {'id': '149', 'type': 'argument_list', 'children': ['150', '151', '152']}; {'id': '150', 'type': 'string', 'children': [], 'value': '"logcfgfile"'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'logcfgfile'}; {'id': '152', 'type': 'None', 'children': []}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '158', 'type': 'argument_list', 'children': ['159']}; {'id': '159', 'type': 'string', 'children': [], 'value': '"Starting sockspy..."'}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'sockspy_main'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'cfg'}
|
Simple python implementation of a socks5 proxy server.
|
def _get_magnitude_term(self, C, mag):
if mag >= self.CONSTS["Mh"]:
return C["e1"] + C["b3"] * (mag - self.CONSTS["Mh"])
else:
return C["e1"] + (C["b1"] * (mag - self.CONSTS["Mh"])) +\
(C["b2"] * (mag - self.CONSTS["Mh"]) ** 2.)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_magnitude_term'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'mag'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '16', '34']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': '>='}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'mag'}; {'id': '11', 'type': 'subscript', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'CONSTS'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"Mh"'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '+'}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"e1"'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '26'], 'value': '*'}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"b3"'}; {'id': '26', 'type': '()', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '-'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'mag'}; {'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': 'CONSTS'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"Mh"'}; {'id': '34', 'type': 'else_clause', 'children': ['35']}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '55', '56'], 'value': '+'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '42'], 'value': '+'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"e1"'}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '47'], 'value': '*'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"b1"'}; {'id': '47', 'type': '()', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '-'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'mag'}; {'id': '50', 'type': 'subscript', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'CONSTS'}; {'id': '54', 'type': 'string', 'children': [], 'value': '"Mh"'}; {'id': '55', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '56', 'type': '()', 'children': ['57']}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '61'], 'value': '*'}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"b2"'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '70'], 'value': '**'}; {'id': '62', 'type': '()', 'children': ['63']}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '-'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'mag'}; {'id': '65', 'type': 'subscript', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'CONSTS'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"Mh"'}; {'id': '70', 'type': 'float', 'children': [], 'value': '2.'}
|
Returns the magnitude scaling term - equation 3
|
def freeze_js(html):
matches = js_src_pattern.finditer(html)
if not matches:
return html
for match in reversed(tuple(matches)):
file_name = match.group(1)
file_path = os.path.join(js_files_path, file_name)
with open(file_path, "r", encoding="utf-8") as f:
file_content = f.read()
fmt = '<script type="text/javascript">{}</script>'
js_content = fmt.format(file_content)
html = html[:match.start()] + js_content + html[match.end():]
return html
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'freeze_js'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '21', '112']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'js_src_pattern'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'finditer'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '18']}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '30']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '30', 'type': 'block', 'children': ['31', '40', '52', '75', '79', '88']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'js_files_path'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '52', 'type': 'with_statement', 'children': ['53', '66']}; {'id': '53', 'type': 'with_clause', 'children': ['54']}; {'id': '54', 'type': 'with_item', 'children': ['55']}; {'id': '55', 'type': 'as_pattern', 'children': ['56', '64']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '61']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"r"'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '63', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '64', 'type': 'as_pattern_target', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'file_content'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'read'}; {'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': 'fmt'}; {'id': '78', 'type': 'string', 'children': [], 'value': '\'<script type="text/javascript">{}</script>\''}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'js_content'}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'file_content'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '103'], 'value': '+'}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '102'], 'value': '+'}; {'id': '93', 'type': 'subscript', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '95', 'type': 'slice', 'children': ['96', '97']}; {'id': '96', 'type': 'colon', 'children': []}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '101', 'type': 'argument_list', 'children': []}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'js_content'}; {'id': '103', 'type': 'subscript', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '105', 'type': 'slice', 'children': ['106', '111']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '110', 'type': 'argument_list', 'children': []}; {'id': '111', 'type': 'colon', 'children': []}; {'id': '112', 'type': 'return_statement', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'html'}
|
Freeze all JS assets to the rendered html itself.
|
def send(term, stream):
payload = erlang.term_to_binary(term)
header = struct.pack('!I', len(payload))
stream.write(header)
stream.write(payload)
stream.flush()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '29', '36', '43']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'erlang'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'term_to_binary'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'term'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'!I'"}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'header'}; {'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': 'stream'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '48', 'type': 'argument_list', 'children': []}
|
Write an Erlang term to an output stream.
|
def extract_full_summary_from_signature(operation):
lines = inspect.getdoc(operation)
regex = r'\s*(:param)\s+(.+?)\s*:(.*)'
summary = ''
if lines:
match = re.search(regex, lines)
summary = lines[:match.regs[0][0]] if match else lines
summary = summary.replace('\n', ' ').replace('\r', '')
return summary
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_full_summary_from_signature'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '19', '23', '53', '69']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'getdoc'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'regex'}; {'id': '18', 'type': 'string', 'children': [], 'value': "r'\\s*(:param)\\s+(.+?)\\s*:(.*)'"}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '22', 'type': 'string', 'children': [], 'value': "''"}; {'id': '23', 'type': 'if_statement', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '25', 'type': 'block', 'children': ['26', '36']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'regex'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '39', 'type': 'conditional_expression', 'children': ['40', '51', '52'], 'value': 'if'}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '42', 'type': 'slice', 'children': ['43', '44']}; {'id': '43', 'type': 'colon', 'children': []}; {'id': '44', 'type': 'subscript', 'children': ['45', '50']}; {'id': '45', 'type': 'subscript', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'regs'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '56', 'type': 'call', 'children': ['57', '66']}; {'id': '57', 'type': 'attribute', 'children': ['58', '65']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'summary'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '64', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'\\r'"}; {'id': '68', 'type': 'string', 'children': [], 'value': "''"}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'summary'}
|
Extract the summary from the docstring of the command.
|
def getParameters(self):
parameters = lock_and_call(
lambda: self._impl.getParameters(),
self._lock
)
return EntityMap(parameters, Parameter)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getParameters'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parameters'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lock_and_call'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '20']}; {'id': '12', 'type': 'lambda', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_impl'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'getParameters'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_lock'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'EntityMap'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'parameters'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Parameter'}
|
Get all the parameters declared.
|
def _color_attr(self, ground, attr):
attr = colors[ground][attr]
attrs = self.cursor_attributes
if ground == "foreground":
self.cursor_attributes = (attrs[0], attr, attrs[2])
elif ground == "background":
self.cursor_attributes = (attrs[0], attrs[1], attr)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_color_attr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ground'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '22']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '11', 'type': 'subscript', 'children': ['12', '15']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ground'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26', '40']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': '=='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ground'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"foreground"'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '32', 'type': 'tuple', 'children': ['33', '36', '37']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '40', 'type': 'elif_clause', 'children': ['41', '44']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': '=='}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ground'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"background"'}; {'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': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '50', 'type': 'tuple', 'children': ['51', '54', '57']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'attr'}
|
Given a color attribute, set the current cursor appropriately.
|
def window_specialization(typename):
return Extension(
'zipline.lib._{name}window'.format(name=typename),
['zipline/lib/_{name}window.pyx'.format(name=typename)],
depends=['zipline/lib/_windowtemplate.pxi'],
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'window_specialization'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'typename'}; {'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': 'Extension'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '18', '27']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'zipline.lib._{name}window'"}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'typename'}; {'id': '18', 'type': 'list', 'children': ['19'], 'value': "['zipline/lib/_{name}window.pyx'.format(name=typename)]"}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'zipline/lib/_{name}window.pyx'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'typename'}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'depends'}; {'id': '29', 'type': 'list', 'children': ['30'], 'value': "['zipline/lib/_windowtemplate.pxi']"}; {'id': '30', 'type': 'string', 'children': [], 'value': "'zipline/lib/_windowtemplate.pxi'"}
|
Make an extension for an AdjustedArrayWindow specialization.
|
def send_mfg_inspector_data(inspector_proto, credentials, destination_url):
envelope = guzzle_pb2.TestRunEnvelope()
envelope.payload = zlib.compress(inspector_proto.SerializeToString())
envelope.payload_type = guzzle_pb2.COMPRESSED_MFG_EVENT
envelope_data = envelope.SerializeToString()
for _ in xrange(5):
try:
result = _send_mfg_inspector_request(
envelope_data, credentials, destination_url)
return result
except UploadFailedError:
time.sleep(1)
logging.critical(
'Could not upload to mfg-inspector after 5 attempts. Giving up.')
return {}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_mfg_inspector_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'inspector_proto'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'destination_url'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '31', '39', '47', '77', '84']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'envelope'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'guzzle_pb2'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'TestRunEnvelope'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'envelope'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'zlib'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'compress'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'inspector_proto'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'SerializeToString'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'envelope'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'payload_type'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'guzzle_pb2'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'COMPRESSED_MFG_EVENT'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'envelope_data'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'envelope'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'SerializeToString'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'for_statement', 'children': ['48', '49', '53']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'try_statement', 'children': ['55', '67']}; {'id': '55', 'type': 'block', 'children': ['56', '65']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_send_mfg_inspector_request'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63', '64']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'envelope_data'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'destination_url'}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '67', 'type': 'except_clause', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'UploadFailedError'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'logging'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'critical'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'Could not upload to mfg-inspector after 5 attempts. Giving up.'"}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'dictionary', 'children': []}
|
Upload MfgEvent to steam_engine.
|
async def fetch_status(self, request):
response = await self._query_validator(
Message.CLIENT_STATUS_GET_REQUEST,
client_status_pb2.ClientStatusGetResponse,
client_status_pb2.ClientStatusGetRequest())
return self._wrap_response(
request,
data={
'peers': response['peers'],
'endpoint': response['endpoint']
},
metadata=self._get_metadata(request, response))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'block', 'children': ['7', '27']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '10', 'type': 'await', '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': '_query_validator'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19', '22']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Message'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'CLIENT_STATUS_GET_REQUEST'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'client_status_pb2'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ClientStatusGetResponse'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'client_status_pb2'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ClientStatusGetRequest'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_wrap_response'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '47']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '36', 'type': 'dictionary', 'children': ['37', '42']}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'peers'"}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'peers'"}; {'id': '42', 'type': 'pair', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'endpoint'"}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'endpoint'"}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_get_metadata'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'response'}
|
Fetches information pertaining to the valiator's status.
|
def _build_models_query(self, query):
registered_models_ct = self.build_models_list()
if registered_models_ct:
restrictions = [xapian.Query('%s%s' % (TERM_PREFIXES[DJANGO_CT], model_ct))
for model_ct in registered_models_ct]
limit_query = xapian.Query(xapian.Query.OP_OR, restrictions)
query = xapian.Query(xapian.Query.OP_AND, query, limit_query)
return query
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_models_query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '66']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'registered_models_ct'}; {'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': 'build_models_list'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'if_statement', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'registered_models_ct'}; {'id': '17', 'type': 'block', 'children': ['18', '37', '51']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'restrictions'}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '34']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'xapian'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Query'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '%'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'%s%s'"}; {'id': '29', 'type': 'tuple', 'children': ['30', '33']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'TERM_PREFIXES'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'DJANGO_CT'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'model_ct'}; {'id': '34', 'type': 'for_in_clause', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'model_ct'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'registered_models_ct'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'limit_query'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'xapian'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Query'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'xapian'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Query'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'OP_OR'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'restrictions'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'xapian'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'Query'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '64', '65']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'xapian'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'Query'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'OP_AND'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'limit_query'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'query'}
|
Builds a query from `query` that filters to documents only from registered models.
|
def calculate_response(self, challenge, password):
to_hash = (challenge + "-" + password).encode("UTF-16LE")
hashed = hashlib.md5(to_hash).hexdigest()
return "{0}-{1}".format(challenge, hashed)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_response'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'challenge'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '7', 'type': 'block', 'children': ['8', '22', '35']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'to_hash'}; {'id': '11', 'type': 'call', 'children': ['12', '20']}; {'id': '12', 'type': 'attribute', 'children': ['13', '19']}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '18'], 'value': '+'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '+'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'challenge'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"-"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"UTF-16LE"'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'hashed'}; {'id': '25', 'type': 'call', 'children': ['26', '34']}; {'id': '26', 'type': 'attribute', 'children': ['27', '33']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'to_hash'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'hexdigest'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"{0}-{1}"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'challenge'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'hashed'}
|
Calculate response for the challenge-response authentication
|
def offset(self, offset):
clone = self._clone()
if isinstance(offset, int):
clone._offset = offset
return clone
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'offset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '28']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'clone'}; {'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': '_clone'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'if_statement', 'children': ['16', '21']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'clone'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_offset'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'clone'}
|
Fetch results after `offset` value
|
def on_backward_end(self, **kwargs):
"Clip the gradient before the optimizer step."
if self.clip: nn.utils.clip_grad_norm_(self.learn.model.parameters(), self.clip)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_backward_end'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '10']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'string', 'children': [], 'value': '"Clip the gradient before the optimizer step."'}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'nn'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'clip_grad_norm_'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '32']}; {'id': '23', 'type': 'call', 'children': ['24', '31']}; {'id': '24', 'type': 'attribute', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'learn'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'parameters'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'clip'}
|
Clip the gradient before the optimizer step.
|
def evalsha(self, digest, keys=[], args=[]):
return self.execute(b'EVALSHA', digest, len(keys), *(keys + args))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'evalsha'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'digest'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '8', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '21', '25']}; {'id': '19', 'type': 'string', 'children': [], 'value': "b'EVALSHA'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'digest'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '25', 'type': 'list_splat', 'children': ['26']}; {'id': '26', 'type': '()', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '+'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'args'}
|
Execute a Lua script server side by its SHA1 digest.
|
def _put_bucket_policy(self):
if self.s3props['bucket_policy']:
policy_str = json.dumps(self.s3props['bucket_policy'])
_response = self.s3client.put_bucket_policy(Bucket=self.bucket, Policy=policy_str)
else:
_response = self.s3client.delete_bucket_policy(Bucket=self.bucket)
LOG.debug('Response adding bucket policy: %s', _response)
LOG.info('S3 Bucket Policy Attached')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_put_bucket_policy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '61', '69']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '44']}; {'id': '7', 'type': 'subscript', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 's3props'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'bucket_policy'"}; {'id': '12', 'type': 'block', 'children': ['13', '26']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'policy_str'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 's3props'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'bucket_policy'"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_response'}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 's3client'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'put_bucket_policy'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '41']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Bucket'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Policy'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'policy_str'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_response'}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 's3client'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'delete_bucket_policy'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'Bucket'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'Response adding bucket policy: %s'"}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_response'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'string', 'children': [], 'value': "'S3 Bucket Policy Attached'"}
|
Attach a bucket policy to app bucket.
|
def _raise_error_if_column_exists(dataset, column_name = 'dataset',
dataset_variable_name = 'dataset',
column_name_error_message_name = 'column_name'):
err_msg = 'The SFrame {0} must contain the column {1}.'.format(
dataset_variable_name,
column_name_error_message_name)
if column_name not in dataset.column_names():
raise ToolkitError(str(err_msg))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_raise_error_if_column_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'dataset'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dataset_variable_name'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'dataset'"}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'column_name_error_message_name'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'column_name'"}; {'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': 'err_msg'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'The SFrame {0} must contain the column {1}.'"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'dataset_variable_name'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'column_name_error_message_name'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '33']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'not in'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'column_names'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'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': 'ToolkitError'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'err_msg'}
|
Check if a column exists in an SFrame with error message.
|
def run(command, **kw):
if sys.platform == 'win32':
_cwd = kw.get('cwd', None)
if _cwd is not None:
kw['cwd'] = _cwd.decode()
try:
return check_output(command, **kw).splitlines()
except CalledProcessError:
return ()
except FileNotFoundError:
print("The {} binary was not found. Skipping directory {}.\n"
.format(command[0], kw['cwd'].decode("UTF-8")))
return ()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '7', 'type': 'block', 'children': ['8', '40']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '13'], 'value': '=='}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'win32'"}; {'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': '_cwd'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'cwd'"}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is not'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_cwd'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'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': 'kw'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'cwd'"}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_cwd'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'try_statement', 'children': ['41', '53', '58']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '52']}; {'id': '44', 'type': 'attribute', 'children': ['45', '51']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'check_output'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '49', 'type': 'dictionary_splat', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'id': '53', 'type': 'except_clause', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'CalledProcessError'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'tuple', 'children': []}; {'id': '58', 'type': 'except_clause', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'FileNotFoundError'}; {'id': '60', 'type': 'block', 'children': ['61', '81']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': '"The {} binary was not found. Skipping directory {}.\\n"'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '73']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'call', 'children': ['74', '79']}; {'id': '74', 'type': 'attribute', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'cwd'"}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'string', 'children': [], 'value': '"UTF-8"'}; {'id': '81', 'type': 'return_statement', 'children': ['82']}; {'id': '82', 'type': 'tuple', 'children': []}
|
Run `command`, catch any exception, and return lines of output.
|
def clear_db():
cursor = '0'
while cursor != 0:
cursor, keys = DB.scan(cursor, match='*', count=5000)
if keys:
DB.delete(*keys)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_db'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'0'"}; {'id': '9', 'type': 'while_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': '!='}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'block', 'children': ['14', '31']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'DB'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'scan'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25', '28']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '5000'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'DB'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'list_splat', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'keys'}
|
Clear the entire db.
|
def update(self, device_json=None, info_json=None, settings_json=None,
avatar_json=None):
if device_json:
UTILS.update(self._device_json, device_json)
if avatar_json:
UTILS.update(self._avatar_json, avatar_json)
if info_json:
UTILS.update(self._info_json, info_json)
if settings_json:
UTILS.update(self._settings_json, settings_json)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'device_json'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'info_json'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'settings_json'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'avatar_json'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '31', '44', '57']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'device_json'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'UTILS'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_device_json'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'device_json'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'avatar_json'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'UTILS'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_avatar_json'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'avatar_json'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'info_json'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'UTILS'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_info_json'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'info_json'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'settings_json'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'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': 'UTILS'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_settings_json'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'settings_json'}
|
Update the internal device json data.
|
def add(self, value):
path = value if isinstance(value, Path) else Path(str(value))
if path and path != path.parent:
destination = self
for part in path.parts:
destination = destination.setdefault(part, DirectoryTree())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'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', '24']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '10', 'type': 'conditional_expression', 'children': ['11', '12', '17'], 'value': 'if'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'value'}; {'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': 'value'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '32']}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '27'], 'value': 'and'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': '!='}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '32', 'type': 'block', 'children': ['33', '37']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '42']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'DirectoryTree'}; {'id': '54', 'type': 'argument_list', 'children': []}
|
Create a safe directory from a value.
|
def report(self, req_handler):
"Send a response corresponding to this error to the client"
if self.exc:
req_handler.send_exception(self.code, self.exc, self.headers)
return
text = (self.text
or BaseHTTPRequestHandler.responses[self.code][1]
or "Unknown error")
getattr(req_handler, "send_error_%s" % self.ctype, 'send_error_msg')(self.code, text, self.headers)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'report'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'req_handler'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '30', '49']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Send a response corresponding to this error to the client"'}; {'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': 'exc'}; {'id': '13', 'type': 'block', 'children': ['14', '29']}; {'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': 'req_handler'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'send_exception'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23', '26']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '29', 'type': 'return_statement', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '33', 'type': '()', 'children': ['34']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '48'], 'value': 'or'}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '39'], 'value': 'or'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '39', 'type': 'subscript', 'children': ['40', '47']}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'BaseHTTPRequestHandler'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'responses'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"Unknown error"'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '61']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '60']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'req_handler'}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '57'], 'value': '%'}; {'id': '56', 'type': 'string', 'children': [], 'value': '"send_error_%s"'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ctype'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'send_error_msg'"}; {'id': '61', 'type': 'argument_list', 'children': ['62', '65', '66']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'headers'}
|
Send a response corresponding to this error to the client
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.