code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def _match_value_filter(self, p, value):
return self._VALUE_FILTER_MAP[p[0]](value[p[1]], p[2])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_match_value_filter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'subscript', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_VALUE_FILTER_MAP'}; {'id': '14', 'type': 'subscript', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '2'}
|
Returns True of False if value in the pattern p matches the filter.
|
def infos(cls, fqdn):
if isinstance(fqdn, (list, tuple)):
ids = []
for fqd_ in fqdn:
ids.extend(cls.infos(fqd_))
return ids
ids = cls.usable_id(fqdn)
if not ids:
return []
if not isinstance(ids, (list, tuple)):
ids = [ids]
return [cls.info(id_) for id_ in ids]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'infos'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fqdn'}; {'id': '6', 'type': 'block', 'children': ['7', '38', '47', '53', '68']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fqdn'}; {'id': '12', 'type': 'tuple', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '15', 'type': 'block', 'children': ['16', '20', '36']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fqd_'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fqdn'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'infos'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'fqd_'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'usable_id'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'fqdn'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '50']}; {'id': '48', 'type': 'not_operator', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '62']}; {'id': '54', 'type': 'not_operator', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '59', 'type': 'tuple', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '66', 'type': 'list', 'children': ['67'], 'value': '[ids]'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'list_comprehension', 'children': ['70', '76']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '76', 'type': 'for_in_clause', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'ids'}
|
Display information about hosted certificates for a fqdn.
|
def clean():
shutil.rmtree(BUILD_PATH, ignore_errors=True)
shutil.rmtree(os.path.join(SOURCE_PATH, 'reference', 'api'),
ignore_errors=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '15']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'call', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'shutil'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'rmtree'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'BUILD_PATH'}; {'id': '12', 'type': 'keyword_argument', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ignore_errors'}; {'id': '14', 'type': 'True', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'shutil'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'rmtree'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '31']}; {'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': 'os'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'SOURCE_PATH'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'reference'"}; {'id': '30', 'type': 'string', 'children': [], 'value': "'api'"}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ignore_errors'}; {'id': '33', 'type': 'True', 'children': []}
|
Clean documentation generated files.
|
def parse_time_arg(s):
try:
return time.strptime(s, "%Y-%m-%d %H:%M")
except ValueError as e:
raise argparse.ArgumentTypeError(e)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_time_arg'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'strptime'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"%Y-%m-%d %H:%M"'}; {'id': '16', 'type': 'except_clause', 'children': ['17', '21']}; {'id': '17', 'type': 'as_pattern', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '19', 'type': 'as_pattern_target', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'argparse'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ArgumentTypeError'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'e'}
|
Parse a time stamp in the "year-month-day hour-minute" format.
|
def words_amount_needed(entropybits: Union[int, float],
entropy_w: Union[int, float],
entropy_n: Union[int, float],
amount_n: int) -> int:
if not isinstance(entropybits, (int, float)):
raise TypeError('entropybits can only be int or float')
if not isinstance(entropy_w, (int, float)):
raise TypeError('entropy_w can only be int or float')
if not isinstance(entropy_n, (int, float)):
raise TypeError('entropy_n can only be int or float')
if not isinstance(amount_n, int):
raise TypeError('amount_n can only be int')
if entropybits < 0:
raise ValueError('entropybits should be greater than 0')
if entropy_w <= 0:
raise ValueError('entropy_w should be greater than 0')
if entropy_n < 0:
raise ValueError('entropy_n should be greater than 0')
if amount_n < 0:
raise ValueError('amount_n should be greater than 0')
amount_w = (entropybits - entropy_n * amount_n) / entropy_w
if amount_w > -1.0:
return ceil(fabs(amount_w))
return 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '38', '40']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'words_amount_needed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '14', '24', '34']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'entropybits'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '9', 'type': 'type_parameter', 'children': ['10', '12']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '14', 'type': 'typed_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'entropy_w'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'generic_type', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '19', 'type': 'type_parameter', 'children': ['20', '22']}; {'id': '20', 'type': 'type', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '22', 'type': 'type', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '24', 'type': 'typed_parameter', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'entropy_n'}; {'id': '26', 'type': 'type', 'children': ['27']}; {'id': '27', 'type': 'generic_type', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '29', 'type': 'type_parameter', 'children': ['30', '32']}; {'id': '30', 'type': 'type', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '32', 'type': 'type', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '34', 'type': 'typed_parameter', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'amount_n'}; {'id': '36', 'type': 'type', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '38', 'type': 'type', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '40', 'type': 'block', 'children': ['41', '56', '71', '86', '99', '109', '119', '129', '139', '150', '164']}; {'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': 'entropybits'}; {'id': '47', 'type': 'tuple', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'raise_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'entropybits can only be int or float'"}; {'id': '56', 'type': 'if_statement', 'children': ['57', '65']}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'entropy_w'}; {'id': '62', 'type': 'tuple', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'raise_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'entropy_w can only be int or float'"}; {'id': '71', 'type': 'if_statement', 'children': ['72', '80']}; {'id': '72', 'type': 'not_operator', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'entropy_n'}; {'id': '77', 'type': 'tuple', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'raise_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'string', 'children': [], 'value': "'entropy_n can only be int or float'"}; {'id': '86', 'type': 'if_statement', 'children': ['87', '93']}; {'id': '87', 'type': 'not_operator', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'amount_n'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'raise_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'amount_n can only be int'"}; {'id': '99', 'type': 'if_statement', 'children': ['100', '103']}; {'id': '100', 'type': 'comparison_operator', 'children': ['101', '102'], 'value': '<'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'entropybits'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'raise_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'string', 'children': [], 'value': "'entropybits should be greater than 0'"}; {'id': '109', 'type': 'if_statement', 'children': ['110', '113']}; {'id': '110', 'type': 'comparison_operator', 'children': ['111', '112'], 'value': '<='}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'entropy_w'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'raise_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'string', 'children': [], 'value': "'entropy_w should be greater than 0'"}; {'id': '119', 'type': 'if_statement', 'children': ['120', '123']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '122'], 'value': '<'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'entropy_n'}; {'id': '122', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'raise_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'string', 'children': [], 'value': "'entropy_n should be greater than 0'"}; {'id': '129', 'type': 'if_statement', 'children': ['130', '133']}; {'id': '130', 'type': 'comparison_operator', 'children': ['131', '132'], 'value': '<'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'amount_n'}; {'id': '132', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'raise_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'string', 'children': [], 'value': "'amount_n should be greater than 0'"}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'amount_w'}; {'id': '142', 'type': 'binary_operator', 'children': ['143', '149'], 'value': '/'}; {'id': '143', 'type': '()', 'children': ['144']}; {'id': '144', 'type': 'binary_operator', 'children': ['145', '146'], 'value': '-'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'entropybits'}; {'id': '146', 'type': 'binary_operator', 'children': ['147', '148'], 'value': '*'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'entropy_n'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'amount_n'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'entropy_w'}; {'id': '150', 'type': 'if_statement', 'children': ['151', '155']}; {'id': '151', 'type': 'comparison_operator', 'children': ['152', '153'], 'value': '>'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'amount_w'}; {'id': '153', 'type': 'unary_operator', 'children': ['154'], 'value': '-'}; {'id': '154', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '155', 'type': 'block', 'children': ['156']}; {'id': '156', 'type': 'return_statement', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'ceil'}; {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'call', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'fabs'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'amount_w'}; {'id': '164', 'type': 'return_statement', 'children': ['165']}; {'id': '165', 'type': 'integer', 'children': [], 'value': '0'}
|
Calculate words needed for a passphrase based on entropy.
|
def _colorize_single_line(line, regexp, color_def):
match = regexp.match(line)
groupdict = match.groupdict()
groups = match.groups()
if not groupdict:
color = color_def[0]
dark = color_def[1]
cprint("%s\n" % line, color, fg_dark=dark)
else:
rev_groups = {v: k for k, v in groupdict.items()}
for part in groups:
if part in rev_groups and rev_groups[part] in color_def:
group_name = rev_groups[part]
cprint(
part,
color_def[group_name][0],
fg_dark=color_def[group_name][1],
)
else:
cprint(part)
cprint("\n")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_colorize_single_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'regexp'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'color_def'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '25', '33']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'regexp'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'if_statement', 'children': ['34', '36', '60']}; {'id': '34', 'type': 'not_operator', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '36', 'type': 'block', 'children': ['37', '43', '49']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'color_def'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dark'}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'color_def'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cprint'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56', '57']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '%'}; {'id': '54', 'type': 'string', 'children': [], 'value': '"%s\\n"'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'fg_dark'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'dark'}; {'id': '60', 'type': 'else_clause', 'children': ['61']}; {'id': '61', 'type': 'block', 'children': ['62', '78', '123']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'rev_groups'}; {'id': '65', 'type': 'dictionary_comprehension', 'children': ['66', '69']}; {'id': '66', 'type': 'pair', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '69', 'type': 'for_in_clause', 'children': ['70', '73']}; {'id': '70', 'type': 'pattern_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'for_statement', 'children': ['79', '80', '81']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'if_statement', 'children': ['83', '92', '116']}; {'id': '83', 'type': 'boolean_operator', 'children': ['84', '87'], 'value': 'and'}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': 'in'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'rev_groups'}; {'id': '87', 'type': 'comparison_operator', 'children': ['88', '91'], 'value': 'in'}; {'id': '88', 'type': 'subscript', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'rev_groups'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'color_def'}; {'id': '92', 'type': 'block', 'children': ['93', '99']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'rev_groups'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'cprint'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104', '109']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '104', 'type': 'subscript', 'children': ['105', '108']}; {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'color_def'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '108', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '109', 'type': 'keyword_argument', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'fg_dark'}; {'id': '111', 'type': 'subscript', 'children': ['112', '115']}; {'id': '112', 'type': 'subscript', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'color_def'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'group_name'}; {'id': '115', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '116', 'type': 'else_clause', 'children': ['117']}; {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'cprint'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'cprint'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'string', 'children': [], 'value': '"\\n"'}
|
Print single line to console with ability to colorize parts of it.
|
def retry_after(cls, response, default=5, _now=time.time):
val = response.headers.getRawHeaders(b'retry-after', [default])[0]
try:
return int(val)
except ValueError:
return http.stringToDatetime(val) - _now()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retry_after'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_now'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '14', 'type': 'block', 'children': ['15', '30']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '18', 'type': 'subscript', 'children': ['19', '29']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'getRawHeaders'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "b'retry-after'"}; {'id': '27', 'type': 'list', 'children': ['28'], 'value': '[default]'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'try_statement', 'children': ['31', '37']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '37', 'type': 'except_clause', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '48'], 'value': '-'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'http'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'stringToDatetime'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_now'}; {'id': '50', 'type': 'argument_list', 'children': []}
|
Parse the Retry-After value from a response.
|
def loads(astring):
try:
return pickle.loads(lzma.decompress(astring))
except lzma.LZMAError as e:
raise SerializerError(
'Cannot decompress object ("{}")'.format(str(e))
)
except pickle.UnpicklingError as e:
raise SerializerError(
'Cannot restore object ("{}")'.format(str(e))
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'loads'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'astring'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '20', '41']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lzma'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'decompress'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'astring'}; {'id': '20', 'type': 'except_clause', 'children': ['21', '27']}; {'id': '21', 'type': 'as_pattern', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'lzma'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'LZMAError'}; {'id': '25', 'type': 'as_pattern_target', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'raise_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'SerializerError'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '\'Cannot decompress object ("{}")\''}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '41', 'type': 'except_clause', 'children': ['42', '48']}; {'id': '42', 'type': 'as_pattern', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'UnpicklingError'}; {'id': '46', 'type': 'as_pattern_target', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'raise_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'SerializerError'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': '\'Cannot restore object ("{}")\''}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'e'}
|
Decompress and deserialize string into a Python object via pickle.
|
def stopping_criteria(self):
"Test whether the stopping criteria has been achieved."
if self.stopping_criteria_tl():
return True
if self.generations < np.inf:
inds = self.popsize * self.generations
flag = inds <= len(self.population.hist)
else:
flag = False
if flag:
return True
est = self.population.estopping
if self._tr_fraction < 1:
if est is not None and est.fitness_vs == 0:
return True
esr = self._early_stopping_rounds
if self._tr_fraction < 1 and esr is not None and est is not None:
position = self.population.estopping.position
if position < self.init_popsize:
position = self.init_popsize
return (len(self.population.hist) +
self._unfeasible_counter -
position) > esr
return flag
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stopping_criteria'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '17', '55', '60', '68', '88', '94', '150']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Test whether the stopping criteria has been achieved."'}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'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': 'stopping_criteria_tl'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'True', 'children': []}; {'id': '17', 'type': 'if_statement', 'children': ['18', '25', '49']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': '<'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'generations'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'inf'}; {'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': 'inds'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '33'], 'value': '*'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'popsize'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'generations'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': '<='}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'inds'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'hist'}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'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': 'flag'}; {'id': '54', 'type': 'False', 'children': []}; {'id': '55', 'type': 'if_statement', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'True', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'est'}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'estopping'}; {'id': '68', 'type': 'if_statement', 'children': ['69', '74']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '73'], 'value': '<'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_tr_fraction'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'if_statement', 'children': ['76', '85']}; {'id': '76', 'type': 'boolean_operator', 'children': ['77', '80'], 'value': 'and'}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '79'], 'value': 'is not'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'est'}; {'id': '79', 'type': 'None', 'children': []}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '84'], 'value': '=='}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'est'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'fitness_vs'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'True', 'children': []}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'esr'}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': '_early_stopping_rounds'}; {'id': '94', 'type': 'if_statement', 'children': ['95', '108']}; {'id': '95', 'type': 'boolean_operator', 'children': ['96', '105'], 'value': 'and'}; {'id': '96', 'type': 'boolean_operator', 'children': ['97', '102'], 'value': 'and'}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '101'], 'value': '<'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '_tr_fraction'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': 'is not'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'esr'}; {'id': '104', 'type': 'None', 'children': []}; {'id': '105', 'type': 'comparison_operator', 'children': ['106', '107'], 'value': 'is not'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'est'}; {'id': '107', 'type': 'None', 'children': []}; {'id': '108', 'type': 'block', 'children': ['109', '119', '132']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '112', 'type': 'attribute', 'children': ['113', '118']}; {'id': '113', 'type': 'attribute', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'estopping'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '119', 'type': 'if_statement', 'children': ['120', '125']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '122'], 'value': '<'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'init_popsize'}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'init_popsize'}; {'id': '132', 'type': 'return_statement', 'children': ['133']}; {'id': '133', 'type': 'comparison_operator', 'children': ['134', '149'], 'value': '>'}; {'id': '134', 'type': '()', 'children': ['135']}; {'id': '135', 'type': 'binary_operator', 'children': ['136', '148'], 'value': '-'}; {'id': '136', 'type': 'binary_operator', 'children': ['137', '145'], 'value': '+'}; {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'attribute', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'hist'}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': '_unfeasible_counter'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'esr'}; {'id': '150', 'type': 'return_statement', 'children': ['151']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'flag'}
|
Test whether the stopping criteria has been achieved.
|
def where_stmt_handle(tokens):
internal_assert(len(tokens) == 2, "invalid where statement tokens", tokens)
base_stmt, assignment_stmts = tokens
stmts = list(assignment_stmts) + [base_stmt]
return "\n".join(stmts) + "\n"
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'where_stmt_handle'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '24', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'internal_assert'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '16', '17']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '15'], 'value': '=='}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"invalid where statement tokens"'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'base_stmt'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'assignment_stmts'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'stmts'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '32'], 'value': '+'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'assignment_stmts'}; {'id': '32', 'type': 'list', 'children': ['33'], 'value': '[base_stmt]'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'base_stmt'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '42'], 'value': '+'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'stmts'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"\\n"'}
|
Process a where statement.
|
def write_config(self, outfile):
utils.write_yaml(self.config, outfile, default_flow_style=False)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'write_yaml'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16', '17']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'default_flow_style'}; {'id': '19', 'type': 'False', 'children': []}
|
Write the configuration dictionary to an output file.
|
def main():
while 1:
events = get_key()
if events:
for event in events:
print(event.ev_type, event.code, event.state)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 'type': 'while_statement', 'children': ['6', '7']}; {'id': '6', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '7', 'type': 'block', 'children': ['8', '14']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_key'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '28', '31']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ev_type'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'state'}
|
Just print out some event infomation when keys are pressed.
|
def backtracking(a, L, bestsofar):
w, j = max(L.items())
while j != -1:
yield j
w, j = bestsofar[j]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'backtracking'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'L'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'bestsofar'}; {'id': '7', 'type': 'block', 'children': ['8', '21']}; {'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': 'w'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'L'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'while_statement', 'children': ['22', '26']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': '!='}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '24', 'type': 'unary_operator', 'children': ['25'], 'value': '-'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'block', 'children': ['27', '30']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'yield', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bestsofar'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'j'}
|
Start with the heaviest weight and emit index
|
def delete(self):
for module in self.compute():
yield from module.instance().project_closing(self)
yield from self._close_and_clean(True)
for module in self.compute():
yield from module.instance().project_closed(self)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '26', '34']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '13']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'module'}; {'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': 'compute'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'yield', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '24']}; {'id': '17', 'type': 'attribute', 'children': ['18', '23']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'project_closing'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'yield', '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': '_close_and_clean'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'True', 'children': []}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '41']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'compute'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'yield', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '52']}; {'id': '45', 'type': 'attribute', 'children': ['46', '51']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'project_closed'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}
|
Removes project from disk
|
def list_keys(self):
key_dirs = self._check_minions_directories()
ret = {}
for dir_ in key_dirs:
if dir_ is None:
continue
ret[os.path.basename(dir_)] = []
try:
for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(dir_)):
if not fn_.startswith('.'):
if os.path.isfile(os.path.join(dir_, fn_)):
ret[os.path.basename(dir_)].append(
salt.utils.stringutils.to_unicode(fn_)
)
except (OSError, IOError):
continue
return ret
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_keys'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '18', '119']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'key_dirs'}; {'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': '_check_minions_directories'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'dir_'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key_dirs'}; {'id': '21', 'type': 'block', 'children': ['22', '28', '41']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'is'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dir_'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'continue_statement', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '40']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'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': 'os'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dir_'}; {'id': '40', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '41', 'type': 'try_statement', 'children': ['42', '113']}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'for_statement', 'children': ['44', '45', '60']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fn_'}; {'id': '45', 'type': 'call', 'children': ['46', '53']}; {'id': '46', 'type': 'attribute', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'sorted_ignorecase'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'listdir'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'dir_'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'if_statement', 'children': ['62', '69']}; {'id': '62', 'type': 'not_operator', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'fn_'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'if_statement', 'children': ['71', '87']}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '84']}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'dir_'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'fn_'}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '102']}; {'id': '90', 'type': 'attribute', 'children': ['91', '101']}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '93', 'type': 'call', 'children': ['94', '99']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'dir_'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '111']}; {'id': '104', 'type': 'attribute', 'children': ['105', '110']}; {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'stringutils'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'to_unicode'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'fn_'}; {'id': '113', 'type': 'except_clause', 'children': ['114', '117']}; {'id': '114', 'type': 'tuple', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'continue_statement', 'children': []}; {'id': '119', 'type': 'return_statement', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'ret'}
|
Return a dict of managed keys and what the key status are
|
def db(self):
if self._db is None:
if self.tcex.default_args.tc_playbook_db_type == 'Redis':
from .tcex_redis import TcExRedis
self._db = TcExRedis(
self.tcex.default_args.tc_playbook_db_path,
self.tcex.default_args.tc_playbook_db_port,
self.tcex.default_args.tc_playbook_db_context,
)
elif self.tcex.default_args.tc_playbook_db_type == 'TCKeyValueAPI':
from .tcex_key_value import TcExKeyValue
self._db = TcExKeyValue(self.tcex)
else:
err = u'Invalid DB Type: ({})'.format(self.tcex.default_args.tc_playbook_db_type)
raise RuntimeError(err)
return self._db
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'db'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '111']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_db'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '23', '60', '89']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '22'], 'value': '=='}; {'id': '15', 'type': 'attribute', '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': 'tcex'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'default_args'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tc_playbook_db_type'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'Redis'"}; {'id': '23', 'type': 'block', 'children': ['24', '31']}; {'id': '24', 'type': 'import_from_statement', 'children': ['25', '29']}; {'id': '25', 'type': 'relative_import', 'children': ['26', '27']}; {'id': '26', 'type': 'import_prefix', 'children': []}; {'id': '27', 'type': 'dotted_name', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'tcex_redis'}; {'id': '29', 'type': 'dotted_name', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'TcExRedis'}; {'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': '_db'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'TcExRedis'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '46', '53']}; {'id': '39', 'type': 'attribute', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'tcex'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'default_args'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'tc_playbook_db_path'}; {'id': '46', 'type': 'attribute', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'tcex'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'default_args'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'tc_playbook_db_port'}; {'id': '53', 'type': 'attribute', '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': 'tcex'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'default_args'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'tc_playbook_db_context'}; {'id': '60', 'type': 'elif_clause', 'children': ['61', '70']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '69'], 'value': '=='}; {'id': '62', 'type': 'attribute', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'tcex'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'default_args'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'tc_playbook_db_type'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'TCKeyValueAPI'"}; {'id': '70', 'type': 'block', 'children': ['71', '78']}; {'id': '71', 'type': 'import_from_statement', 'children': ['72', '76']}; {'id': '72', 'type': 'relative_import', 'children': ['73', '74']}; {'id': '73', 'type': 'import_prefix', 'children': []}; {'id': '74', 'type': 'dotted_name', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'tcex_key_value'}; {'id': '76', 'type': 'dotted_name', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'TcExKeyValue'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_db'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'TcExKeyValue'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'tcex'}; {'id': '89', 'type': 'else_clause', 'children': ['90']}; {'id': '90', 'type': 'block', 'children': ['91', '106']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': "u'Invalid DB Type: ({})'"}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'attribute', 'children': ['100', '105']}; {'id': '100', 'type': 'attribute', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'tcex'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'default_args'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'tc_playbook_db_type'}; {'id': '106', 'type': 'raise_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '111', 'type': 'return_statement', 'children': ['112']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_db'}
|
Return the correct KV store for this execution.
|
def rlmf_tictactoe():
hparams = rlmf_original()
hparams.game = "tictactoe"
hparams.rl_env_name = "T2TEnv-TicTacToeEnv-v0"
hparams.eval_max_num_noops = 0
hparams.max_num_noops = 0
hparams.rl_should_derive_observation_space = False
hparams.policy_network = "feed_forward_categorical_policy"
hparams.base_algo_params = "ppo_ttt_params"
hparams.frame_stack_size = 1
return hparams
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rlmf_tictactoe'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '17', '23', '29', '35', '41', '47', '53', '59']}; {'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', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'rlmf_original'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'game'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"tictactoe"'}; {'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': 'hparams'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rl_env_name'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"T2TEnv-TicTacToeEnv-v0"'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'eval_max_num_noops'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'max_num_noops'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'rl_should_derive_observation_space'}; {'id': '40', 'type': 'False', 'children': []}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'policy_network'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"feed_forward_categorical_policy"'}; {'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': 'hparams'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'base_algo_params'}; {'id': '52', 'type': 'string', 'children': [], 'value': '"ppo_ttt_params"'}; {'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': 'hparams'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'frame_stack_size'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'hparams'}
|
Base set of hparams for model-free PPO.
|
def new_mountpoint(self, name):
url = posixpath.join(self.path, name)
r = self._jfs.post(url, extra_headers={'content-type': 'application/x-www-form-urlencoded'})
return r
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'new_mountpoint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '36']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'posixpath'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'r'}; {'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': '_jfs'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'extra_headers'}; {'id': '32', 'type': 'dictionary', 'children': ['33']}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'content-type'"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'application/x-www-form-urlencoded'"}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'r'}
|
Create a new mountpoint
|
def map_over_glob(fn, path, pattern):
return [fn(x) for x in glob.glob(os.path.join(path, pattern))]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_over_glob'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '14']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '14', 'type': 'for_in_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pattern'}
|
map a function over a glob pattern, relative to a directory
|
def _collection_function_inclusion_builder(funcs: Iterable[str]) -> NodePredicate:
funcs = set(funcs)
if not funcs:
raise ValueError('can not build function inclusion filter with empty list of functions')
def functions_inclusion_filter(_: BELGraph, node: BaseEntity) -> bool:
return node.function in funcs
return functions_inclusion_filter
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_collection_function_inclusion_builder'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'funcs'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Iterable'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'NodePredicate'}; {'id': '14', 'type': 'block', 'children': ['15', '22', '31', '51']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'funcs'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'funcs'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '25']}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'funcs'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'can not build function inclusion filter with empty list of functions'"}; {'id': '31', 'type': 'function_definition', 'children': ['32', '33', '42', '44']}; {'id': '32', 'type': 'function_name', 'children': [], 'value': 'functions_inclusion_filter'}; {'id': '33', 'type': 'parameters', 'children': ['34', '38']}; {'id': '34', 'type': 'typed_parameter', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '36', 'type': 'type', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'BELGraph'}; {'id': '38', 'type': 'typed_parameter', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '40', 'type': 'type', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'BaseEntity'}; {'id': '42', 'type': 'type', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '50'], 'value': 'in'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'funcs'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'functions_inclusion_filter'}
|
Build a function inclusion filter for a collection of functions.
|
def wait(self):
"wait for a message, respecting timeout"
data=self.getcon().recv(256)
if not data: raise PubsubDisco
if self.reset:
self.reset=False
raise PubsubDisco
self.buf+=data
msg,self.buf=complete_message(self.buf)
return msg
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '21', '27', '40', '46', '59']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"wait for a message, respecting timeout"'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getcon'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'recv'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '24']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'PubsubDisco'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '31', 'type': 'block', 'children': ['32', '38']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '37', 'type': 'False', 'children': []}; {'id': '38', 'type': 'raise_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'PubsubDisco'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'augmented_assignment', 'children': ['42', '45'], 'value': '+='}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '53']}; {'id': '48', 'type': 'pattern_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'complete_message'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'msg'}
|
wait for a message, respecting timeout
|
def block17(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):
with tf.variable_scope(scope, 'Block17', [net], reuse=reuse):
with tf.variable_scope('Branch_0'):
tower_conv = slim.conv2d(net, 192, 1, scope='Conv2d_1x1')
with tf.variable_scope('Branch_1'):
tower_conv1_0 = slim.conv2d(net, 128, 1, scope='Conv2d_0a_1x1')
tower_conv1_1 = slim.conv2d(tower_conv1_0, 160, [1, 7],
scope='Conv2d_0b_1x7')
tower_conv1_2 = slim.conv2d(tower_conv1_1, 192, [7, 1],
scope='Conv2d_0c_7x1')
mixed = tf.concat(axis=3, values=[tower_conv, tower_conv1_2])
up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,
activation_fn=None, scope='Conv2d_1x1')
net += scale * up
if activation_fn:
net = activation_fn(net)
return net
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'block17'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '15', '18']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '7', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'activation_fn'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'nn'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'relu'}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'reuse'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '176']}; {'id': '22', 'type': 'with_statement', 'children': ['23', '37']}; {'id': '23', 'type': 'with_clause', 'children': ['24']}; {'id': '24', 'type': 'with_item', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'variable_scope'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31', '32', '34']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'Block17'"}; {'id': '32', 'type': 'list', 'children': ['33'], 'value': '[net]'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'reuse'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'reuse'}; {'id': '37', 'type': 'block', 'children': ['38', '62', '118', '134', '160', '166']}; {'id': '38', 'type': 'with_statement', 'children': ['39', '47']}; {'id': '39', 'type': 'with_clause', 'children': ['40']}; {'id': '40', 'type': 'with_item', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'variable_scope'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'Branch_0'"}; {'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': 'tower_conv'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'slim'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'conv2d'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57', '58', '59']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '192'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'Conv2d_1x1'"}; {'id': '62', 'type': 'with_statement', 'children': ['63', '71']}; {'id': '63', 'type': 'with_clause', 'children': ['64']}; {'id': '64', 'type': 'with_item', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'variable_scope'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'Branch_1'"}; {'id': '71', 'type': 'block', 'children': ['72', '86', '102']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'tower_conv1_0'}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'slim'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'conv2d'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81', '82', '83']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '128'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'Conv2d_0a_1x1'"}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'tower_conv1_1'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'slim'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'conv2d'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95', '96', '99']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'tower_conv1_0'}; {'id': '95', 'type': 'integer', 'children': [], 'value': '160'}; {'id': '96', 'type': 'list', 'children': ['97', '98'], 'value': '[1, 7]'}; {'id': '97', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'Conv2d_0b_1x7'"}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'tower_conv1_2'}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'slim'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'conv2d'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111', '112', '115']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'tower_conv1_1'}; {'id': '111', 'type': 'integer', 'children': [], 'value': '192'}; {'id': '112', 'type': 'list', 'children': ['113', '114'], 'value': '[7, 1]'}; {'id': '113', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '114', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '115', 'type': 'keyword_argument', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '117', 'type': 'string', 'children': [], 'value': "'Conv2d_0c_7x1'"}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'assignment', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'mixed'}; {'id': '121', 'type': 'call', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'concat'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '129']}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '128', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '129', 'type': 'keyword_argument', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '131', 'type': 'list', 'children': ['132', '133'], 'value': '[tower_conv, tower_conv1_2]'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'tower_conv'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'tower_conv1_2'}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'up'}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'slim'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'conv2d'}; {'id': '141', 'type': 'argument_list', 'children': ['142', '143', '150', '151', '154', '157']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'mixed'}; {'id': '143', 'type': 'subscript', 'children': ['144', '149']}; {'id': '144', 'type': 'call', 'children': ['145', '148']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'get_shape'}; {'id': '148', 'type': 'argument_list', 'children': []}; {'id': '149', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '150', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '151', 'type': 'keyword_argument', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'normalizer_fn'}; {'id': '153', 'type': 'None', 'children': []}; {'id': '154', 'type': 'keyword_argument', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'activation_fn'}; {'id': '156', 'type': 'None', 'children': []}; {'id': '157', 'type': 'keyword_argument', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '159', 'type': 'string', 'children': [], 'value': "'Conv2d_1x1'"}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'augmented_assignment', 'children': ['162', '163'], 'value': '+='}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '163', 'type': 'binary_operator', 'children': ['164', '165'], 'value': '*'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'up'}; {'id': '166', 'type': 'if_statement', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'activation_fn'}; {'id': '168', 'type': 'block', 'children': ['169']}; {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'assignment', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '172', 'type': 'call', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'activation_fn'}; {'id': '174', 'type': 'argument_list', 'children': ['175']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'net'}; {'id': '176', 'type': 'return_statement', 'children': ['177']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'net'}
|
Builds the 17x17 resnet block.
|
def validate_port_or_colon_separated_port_range(port_range):
if port_range.count(':') > 1:
raise ValidationError(_("One colon allowed in port range"))
ports = port_range.split(':')
for port in ports:
validate_port_range(port)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_port_or_colon_separated_port_range'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'port_range'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '33']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '14'], 'value': '>'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'port_range'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'ValidationError'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"One colon allowed in port range"'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ports'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'port_range'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ports'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'validate_port_range'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'port'}
|
Accepts a port number or a single-colon separated range.
|
def iexpand(string, keep_escapes=False):
if isinstance(string, bytes):
is_bytes = True
string = string.decode('latin-1')
else:
is_bytes = False
if is_bytes:
return (entry.encode('latin-1') for entry in ExpandBrace(keep_escapes).expand(string))
else:
return (entry for entry in ExpandBrace(keep_escapes).expand(string))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iexpand'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'keep_escapes'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '35']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15', '29']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '15', 'type': 'block', 'children': ['16', '20']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'is_bytes'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'latin-1'"}; {'id': '29', 'type': 'else_clause', 'children': ['30']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'is_bytes'}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '37', '57']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'is_bytes'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'generator_expression', 'children': ['40', '46']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'latin-1'"}; {'id': '46', 'type': 'for_in_clause', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '48', 'type': 'call', 'children': ['49', '55']}; {'id': '49', 'type': 'attribute', 'children': ['50', '54']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ExpandBrace'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'keep_escapes'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'expand'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '57', 'type': 'else_clause', 'children': ['58']}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'generator_expression', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '62', 'type': 'for_in_clause', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '64', 'type': 'call', 'children': ['65', '71']}; {'id': '65', 'type': 'attribute', 'children': ['66', '70']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'ExpandBrace'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'keep_escapes'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'expand'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'string'}
|
Expand braces and return an iterator.
|
def fenceloader(self):
if not self.target_system in self.fenceloader_by_sysid:
self.fenceloader_by_sysid[self.target_system] = mavwp.MAVFenceLoader()
return self.fenceloader_by_sysid[self.target_system]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fenceloader'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '30']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'in'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'target_system'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fenceloader_by_sysid'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '25']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fenceloader_by_sysid'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'target_system'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'mavwp'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'MAVFenceLoader'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'fenceloader_by_sysid'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'target_system'}
|
fence loader by sysid
|
def rle_encode(img:NPArrayMask)->str:
"Return run-length encoding string from `img`."
pixels = np.concatenate([[0], img.flatten() , [0]])
runs = np.where(pixels[1:] != pixels[:-1])[0] + 1
runs[1::2] -= runs[::2]
return ' '.join(str(x) for x in runs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rle_encode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'NPArrayMask'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '10', 'type': 'block', 'children': ['11', '13', '31', '55', '70']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"Return run-length encoding string from `img`."'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pixels'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'concatenate'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'list', 'children': ['22', '24', '29'], 'value': '[[0], img.flatten() , [0]]'}; {'id': '22', 'type': 'list', 'children': ['23'], 'value': '[0]'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'list', 'children': ['30'], 'value': '[0]'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '54'], 'value': '+'}; {'id': '35', 'type': 'subscript', 'children': ['36', '53']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '47'], 'value': '!='}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'pixels'}; {'id': '44', 'type': 'slice', 'children': ['45', '46']}; {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'colon', 'children': []}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'pixels'}; {'id': '49', 'type': 'slice', 'children': ['50', '51']}; {'id': '50', 'type': 'colon', 'children': []}; {'id': '51', 'type': 'unary_operator', 'children': ['52'], 'value': '-'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'augmented_assignment', 'children': ['57', '64'], 'value': '-='}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '59', 'type': 'slice', 'children': ['60', '61', '62', '63']}; {'id': '60', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '61', 'type': 'colon', 'children': []}; {'id': '62', 'type': 'colon', 'children': []}; {'id': '63', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '64', 'type': 'subscript', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '66', 'type': 'slice', 'children': ['67', '68', '69']}; {'id': '67', 'type': 'colon', 'children': []}; {'id': '68', 'type': 'colon', 'children': []}; {'id': '69', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '75', 'type': 'generator_expression', 'children': ['76', '80']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '80', 'type': 'for_in_clause', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'runs'}
|
Return run-length encoding string from `img`.
|
def print_all_dockerfiles(collector, **kwargs):
for name, image in collector.configuration["images"].items():
print("{0}".format(name))
print("-" * len(name))
kwargs["image"] = image
print_dockerfile(collector, **kwargs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_all_dockerfiles'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '12', '21']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '12', 'type': 'call', 'children': ['13', '20']}; {'id': '13', 'type': 'attribute', 'children': ['14', '19']}; {'id': '14', 'type': 'subscript', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'configuration'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"images"'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '32', '42', '48']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"{0}"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'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': 'binary_operator', 'children': ['37', '38'], 'value': '*'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"-"'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"image"'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'print_dockerfile'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '53', 'type': 'dictionary_splat', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Print all the dockerfiles
|
def lam_at_index(self, lidx):
if self.path_ is None:
return self.lam * self.lam_scale_
return self.lam * self.lam_scale_ * self.path_[lidx]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lam_at_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'lidx'}; {'id': '6', 'type': 'block', 'children': ['7', '22']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'path_'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '19'], 'value': '*'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'lam'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'lam_scale_'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '31'], 'value': '*'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '28'], 'value': '*'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'lam'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'lam_scale_'}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'path_'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'lidx'}
|
Compute the scaled lambda used at index lidx.
|
def allLobbySlots(self):
if self.debug:
p = ["Lobby Configuration detail:"] + \
[" %s:%s%s"%(p, " "*(12-len(p.type)), p.name)]
if self.observers:
p += [" observers: %d"%self.observers]
print(os.linesep.join(p))
return (self.agents, self.computers, self.observers)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'allLobbySlots'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '63']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '10', 'type': 'block', 'children': ['11', '37', '51']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '17', '18'], 'value': '+'}; {'id': '15', 'type': 'list', 'children': ['16'], 'value': '["Lobby Configuration detail:"]'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"Lobby Configuration detail:"'}; {'id': '17', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '18', 'type': 'list', 'children': ['19'], 'value': '[" %s:%s%s"%(p, " "*(12-len(p.type)), p.name)]'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '%'}; {'id': '20', 'type': 'string', 'children': [], 'value': '" %s:%s%s"'}; {'id': '21', 'type': 'tuple', 'children': ['22', '23', '34']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '*'}; {'id': '24', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '25', 'type': '()', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '28'], 'value': '-'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '12'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'observers'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'augmented_assignment', 'children': ['44', '45'], 'value': '+='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '45', 'type': 'list', 'children': ['46'], 'value': '[" observers: %d"%self.observers]'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '%'}; {'id': '47', 'type': 'string', 'children': [], 'value': '" observers: %d"'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'observers'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'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': 'linesep'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'tuple', 'children': ['65', '68', '71']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'agents'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'computers'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'observers'}
|
the current configuration of the lobby's players, defined before the match starts
|
def check_hamster(self):
try:
todays_facts = self.storage._Storage__get_todays_facts()
self.check_user(todays_facts)
except Exception as e:
logger.error("Error while refreshing: %s" % e)
finally:
return True
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_hamster'}; {'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', '25', '40']}; {'id': '7', 'type': 'block', 'children': ['8', '18']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'todays_facts'}; {'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': 'storage'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_Storage__get_todays_facts'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'check_user'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'todays_facts'}; {'id': '25', 'type': 'except_clause', 'children': ['26', '30']}; {'id': '26', 'type': 'as_pattern', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '28', 'type': 'as_pattern_target', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '%'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"Error while refreshing: %s"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '40', 'type': 'finally_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'True', 'children': []}
|
refresh hamster every x secs - load today, check last activity etc.
|
def submit_query_request(end_point, *args, **kwargs):
ev_limit = kwargs.pop('ev_limit', 10)
best_first = kwargs.pop('best_first', True)
tries = kwargs.pop('tries', 2)
query_str = '?' + '&'.join(['%s=%s' % (k, v) for k, v in kwargs.items()
if v is not None]
+ list(args))
return submit_statement_request('get', end_point, query_str,
ev_limit=ev_limit, best_first=best_first,
tries=tries)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'submit_query_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'end_point'}; {'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', '20', '30', '40', '74']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ev_limit'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'ev_limit'"}; {'id': '19', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'best_first'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'best_first'"}; {'id': '29', 'type': 'True', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tries'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'tries'"}; {'id': '39', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'query_str'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '+'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'?'"}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'&'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '70'], 'value': '+'}; {'id': '51', 'type': 'list_comprehension', 'children': ['52', '57', '66']}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '%'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'%s=%s'"}; {'id': '54', 'type': 'tuple', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '57', 'type': 'for_in_clause', 'children': ['58', '61']}; {'id': '58', 'type': 'pattern_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '65', 'type': 'argument_list', 'children': []}; {'id': '66', 'type': 'if_clause', 'children': ['67']}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': 'is not'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '69', 'type': 'None', 'children': []}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'submit_statement_request'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79', '80', '81', '84', '87']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'get'"}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'end_point'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'query_str'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'ev_limit'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'ev_limit'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'best_first'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'best_first'}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'tries'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'tries'}
|
Low level function to format the query string.
|
def tooltip_query(self, widget, x, y, keyboard_mode, tooltip):
tooltip.set_text(subprocess.getoutput("acpi"))
return True
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tooltip_query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'widget'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'keyboard_mode'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'tooltip'}; {'id': '10', 'type': 'block', 'children': ['11', '23']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tooltip'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'set_text'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'getoutput'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"acpi"'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'True', 'children': []}
|
Set tooltip which appears when you hover mouse curson onto icon in system panel.
|
def reversed(self):
return Arc(self.end, self.radius, self.rotation, self.large_arc,
not self.sweep, self.start)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reversed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Arc'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '13', '16', '19', '22', '26']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'radius'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rotation'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'large_arc'}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sweep'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'start'}
|
returns a copy of the Arc object with its orientation reversed.
|
def drive(self):
if self.is_drive:
return self
cleartext = self.luks_cleartext_slave
if cleartext:
return cleartext.drive
if self.is_block:
return self._daemon[self._P.Block.Drive]
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'drive'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '19', '26', '43']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'is_drive'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cleartext'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'luks_cleartext_slave'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cleartext'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cleartext'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'drive'}; {'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': 'is_block'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'subscript', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_daemon'}; {'id': '36', 'type': 'attribute', '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': '_P'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Block'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Drive'}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'None', 'children': []}
|
Get wrapper to the drive containing this device.
|
def download_and_extract_to_mkdtemp(bucket, key, session=None):
if session:
s3_client = session.client('s3')
else:
s3_client = boto3.client('s3')
transfer = S3Transfer(s3_client)
filedes, temp_file = tempfile.mkstemp()
os.close(filedes)
transfer.download_file(bucket, key, temp_file)
output_dir = tempfile.mkdtemp()
zip_ref = zipfile.ZipFile(temp_file, 'r')
zip_ref.extractall(output_dir)
zip_ref.close()
os.remove(temp_file)
return output_dir
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'download_and_extract_to_mkdtemp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '33', '40', '50', '57', '66', '74', '84', '91', '97', '104']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '12', '22']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 's3_client'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'s3'"}; {'id': '22', 'type': 'else_clause', 'children': ['23']}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 's3_client'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'boto3'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'s3'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'S3Transfer'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 's3_client'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'pattern_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'filedes'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'tempfile'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'mkstemp'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'filedes'}; {'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': 'transfer'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'download_file'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64', '65']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'output_dir'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'tempfile'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'mkdtemp'}; {'id': '73', 'type': 'argument_list', 'children': []}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'zip_ref'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'zipfile'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ZipFile'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '83', 'type': 'string', 'children': [], 'value': "'r'"}; {'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': 'zip_ref'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'extractall'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'output_dir'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'zip_ref'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'temp_file'}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'output_dir'}
|
Download zip archive and extract it to temporary directory.
|
def DEFINE_bool(self, name, default, help, constant=False):
self.AddOption(
type_info.Bool(name=name, default=default, description=help),
constant=constant)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DEFINE_bool'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'constant'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'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': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'AddOption'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '32']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'type_info'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Bool'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26', '29']}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'constant'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'constant'}
|
A helper for defining boolean options.
|
def filter_decimal(string, default=None, lower=None, upper=None):
try:
d = decimal.Decimal(string)
if lower is not None and d < lower:
raise InvalidInputError("value too small")
if upper is not None and d >= upper:
raise InvalidInputError("value too large")
return d
except decimal.InvalidOperation:
if not string and default is not None:
return default
else:
raise InvalidInputError("invalid decimal number")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_decimal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'try_statement', 'children': ['16', '56']}; {'id': '16', 'type': 'block', 'children': ['17', '26', '40', '54']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'decimal'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Decimal'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '34']}; {'id': '27', 'type': 'boolean_operator', 'children': ['28', '31'], 'value': 'and'}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': 'is not'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': '<'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'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': 'InvalidInputError'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"value too small"'}; {'id': '40', 'type': 'if_statement', 'children': ['41', '48']}; {'id': '41', 'type': 'boolean_operator', 'children': ['42', '45'], 'value': 'and'}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'is not'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '47'], 'value': '>='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'raise_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'InvalidInputError'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': '"value too large"'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '56', 'type': 'except_clause', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'decimal'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'InvalidOperation'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'if_statement', 'children': ['62', '68', '71']}; {'id': '62', 'type': 'boolean_operator', 'children': ['63', '65'], 'value': 'and'}; {'id': '63', 'type': 'not_operator', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': 'is not'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '67', 'type': 'None', 'children': []}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '71', 'type': 'else_clause', 'children': ['72']}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'raise_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'InvalidInputError'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'string', 'children': [], 'value': '"invalid decimal number"'}
|
Return the input decimal number, or the default.
|
def patch_lustre_path(f_path):
if CHECK_LUSTRE_PATH_LEN and len(f_path) == 60:
if os.path.isabs(f_path):
f_path = '/.' + f_path
else:
f_path = './' + f_path
return f_path
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'patch_lustre_path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f_path'}; {'id': '5', 'type': 'block', 'children': ['6', '40']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '9'], 'value': 'and'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'CHECK_LUSTRE_PATH_LEN'}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '14'], 'value': '=='}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'f_path'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '25', '32']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'isabs'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'f_path'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'f_path'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '+'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'/.'"}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'f_path'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'f_path'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '+'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'./'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'f_path'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'f_path'}
|
Patch any 60-character pathnames, to avoid a current Lustre bug.
|
def json(self):
if six.PY3:
return json.loads(self.body.decode(self.charset))
else:
return json.loads(self.body)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10', '27']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'PY3'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'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': 'charset'}; {'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', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'body'}
|
Return response body deserialized into JSON object.
|
def create_python_worker(self, func, *args, **kwargs):
worker = PythonWorker(func, args, kwargs)
self._create_worker(worker)
return worker
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_python_worker'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '20', '27']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'worker'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'PythonWorker'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_create_worker'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'worker'}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'worker'}
|
Create a new python worker instance.
|
def to_json(value, **kwargs):
if isinstance(value, HasProperties):
return value.serialize(**kwargs)
return value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '23']}; {'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': 'value'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'HasProperties'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'serialize'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'dictionary_splat', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Return value, serialized if value is a HasProperties instance
|
def unexpected(lexer: Lexer, at_token: Token = None) -> GraphQLError:
token = at_token or lexer.token
return GraphQLSyntaxError(lexer.source, token.start, f"Unexpected {token.desc}")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unexpected'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'lexer'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'Lexer'}; {'id': '8', 'type': 'typed_default_parameter', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'at_token'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Token'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'GraphQLError'}; {'id': '15', 'type': 'block', 'children': ['16', '24']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '21'], 'value': 'or'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'at_token'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'lexer'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'GraphQLSyntaxError'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31', '34']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'lexer'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '34', 'type': 'string', 'children': [], 'value': 'f"Unexpected {token.desc}"'}
|
Create an error when an unexpected lexed token is encountered.
|
def use_plenary_gradebook_column_view(self):
self._object_views['gradebook_column'] = PLENARY
for session in self._get_provider_sessions():
try:
session.use_plenary_gradebook_column_view()
except AttributeError:
pass
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'use_plenary_gradebook_column_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '13']}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_object_views'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'gradebook_column'"}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'PLENARY'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_get_provider_sessions'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'try_statement', 'children': ['23', '30']}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'use_plenary_gradebook_column_view'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'except_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'pass_statement', 'children': []}
|
Pass through to provider GradebookColumnLookupSession.use_plenary_gradebook_column_view
|
def fields(self, value):
if type(value) is list:
self._fields = value
else:
raise TypeError("Input must be a list")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fields'}; {'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', '14', '21']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': 'is'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'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': '_fields'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'else_clause', 'children': ['22']}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'raise_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"Input must be a list"'}
|
sets the fields variable
|
def save_setup_command(argv, build_path):
file_name = os.path.join(build_path, 'setup_command')
with open(file_name, 'w') as f:
f.write(' '.join(argv[:]) + '\n')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_setup_command'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'build_path'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'build_path'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'setup_command'"}; {'id': '19', 'type': 'with_statement', 'children': ['20', '30']}; {'id': '20', 'type': 'with_clause', 'children': ['21']}; {'id': '21', 'type': 'with_item', 'children': ['22']}; {'id': '22', 'type': 'as_pattern', 'children': ['23', '28']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '28', 'type': 'as_pattern_target', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '47'], 'value': '+'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '45', 'type': 'slice', 'children': ['46']}; {'id': '46', 'type': 'colon', 'children': []}; {'id': '47', 'type': 'string', 'children': [], 'value': "'\\n'"}
|
Save setup command to a file.
|
def create_environment(self, name, default=False, zone=None):
from qubell.api.private.environment import Environment
return Environment.new(organization=self, name=name, zone_id=zone, default=default, router=self._router)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_environment'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'zone'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '21']}; {'id': '13', 'type': 'import_from_statement', 'children': ['14', '19']}; {'id': '14', 'type': 'dotted_name', 'children': ['15', '16', '17', '18']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'qubell'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'private'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'environment'}; {'id': '19', 'type': 'dotted_name', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'Environment'}; {'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': 'Environment'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30', '33', '36', '39']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'organization'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'zone_id'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'zone'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'router'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_router'}
|
Creates environment and returns Environment object.
|
def _progress_hook(self, blocknum, blocksize, totalsize):
read = blocknum * blocksize
if totalsize > 0:
percent = read * 1e2 / totalsize
s = "\r%d%% %*d / %d" % (
percent, len(str(totalsize)), read, totalsize)
sys.stdout.write(s)
if read >= totalsize:
sys.stdout.write("\n")
else:
sys.stdout.write("read %d\n" % read)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_progress_hook'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'blocknum'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'blocksize'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'totalsize'}; {'id': '8', 'type': 'block', 'children': ['9', '15']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '14'], 'value': '*'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'blocknum'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'blocksize'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19', '67']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '>'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'totalsize'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'block', 'children': ['20', '28', '44', '53']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'percent'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '27'], 'value': '/'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '*'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '26', 'type': 'float', 'children': [], 'value': '1e2'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'totalsize'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '%'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"\\r%d%% %*d / %d"'}; {'id': '33', 'type': 'tuple', 'children': ['34', '35', '42', '43']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'percent'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'len'}; {'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': 'totalsize'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'totalsize'}; {'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': 'sys'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '57']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': '>='}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'totalsize'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '67', 'type': 'else_clause', 'children': ['68']}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '76']}; {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '79'], 'value': '%'}; {'id': '78', 'type': 'string', 'children': [], 'value': '"read %d\\n"'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'read'}
|
Progress hook for urlretrieve.
|
def delete_sp_template_for_vlan(self, vlan_id):
with self.session.begin(subtransactions=True):
try:
self.session.query(
ucsm_model.ServiceProfileTemplate).filter_by(
vlan_id=vlan_id).delete()
except orm.exc.NoResultFound:
return
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_sp_template_for_vlan'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'vlan_id'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '20']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'begin'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'subtransactions'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'try_statement', 'children': ['22', '45']}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '44']}; {'id': '25', 'type': 'attribute', 'children': ['26', '43']}; {'id': '26', 'type': 'call', 'children': ['27', '39']}; {'id': '27', 'type': 'attribute', 'children': ['28', '38']}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ucsm_model'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ServiceProfileTemplate'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'filter_by'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'vlan_id'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'vlan_id'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'except_clause', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'orm'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'NoResultFound'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'return_statement', 'children': []}
|
Deletes SP Template for a vlan_id if it exists.
|
def previous_blocks(self, quantity=-1):
blocks = (EighthBlock.objects.get_blocks_this_year().order_by(
"-date", "-block_letter").filter(Q(date__lt=self.date) | (Q(date=self.date) & Q(block_letter__lt=self.block_letter))))
if quantity == -1:
return reversed(blocks)
return reversed(blocks[:quantity])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'previous_blocks'}; {'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': 'quantity'}; {'id': '7', 'type': 'unary_operator', 'children': ['8'], 'value': '-'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '9', 'type': 'block', 'children': ['10', '58', '69']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'blocks'}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '30']}; {'id': '15', 'type': 'attribute', 'children': ['16', '29']}; {'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': 'EighthBlock'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_blocks_this_year'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'order_by'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"-date"'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"-block_letter"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '40'], 'value': '|'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'date__lt'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '50'], 'value': '&'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'block_letter__lt'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'block_letter'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '63']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': '=='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'quantity'}; {'id': '61', 'type': 'unary_operator', 'children': ['62'], 'value': '-'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'blocks'}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'blocks'}; {'id': '75', 'type': 'slice', 'children': ['76', '77']}; {'id': '76', 'type': 'colon', 'children': []}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'quantity'}
|
Get the previous blocks in order.
|
def ansi_len(string):
return len(string) - wcswidth(re.compile(r'\x1b[^m]*m').sub('', string))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ansi_len'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'binary_operator', 'children': ['8', '12'], 'value': '-'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'wcswidth'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '24']}; {'id': '16', 'type': 'attribute', 'children': ['17', '23']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "r'\\x1b[^m]*m'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "''"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'string'}
|
Extra length due to any ANSI sequences in the string.
|
def monkey_patch():
reset()
time_mod.time = time
time_mod.sleep = sleep
time_mod.gmtime = gmtime
time_mod.localtime = localtime
time_mod.ctime = ctime
time_mod.asctime = asctime
time_mod.strftime = strftime
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'monkey_patch'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '15', '21', '27', '33', '39', '45']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'call', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'reset'}; {'id': '8', 'type': 'argument_list', 'children': []}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'time_mod'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'time'}; {'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': 'time_mod'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'time_mod'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'gmtime'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'gmtime'}; {'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': 'time_mod'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'localtime'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'localtime'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'time_mod'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ctime'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ctime'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'time_mod'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'asctime'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'asctime'}; {'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': 'time_mod'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'strftime'}
|
monkey patch `time` module to use out versions
|
def cli(env, identifier, sortby, cpu, domain, hostname, memory, tag, columns):
mgr = SoftLayer.DedicatedHostManager(env.client)
guests = mgr.list_guests(host_id=identifier,
cpus=cpu,
hostname=hostname,
domain=domain,
memory=memory,
tags=tag,
mask=columns.mask())
table = formatting.Table(columns.columns)
table.sortby = sortby
for guest in guests:
table.add_row([value or formatting.blank()
for value in columns.row(guest)])
env.fout(table)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cpu'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'hostname'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'memory'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '13', 'type': 'block', 'children': ['14', '25', '58', '69', '75', '101']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'mgr'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'SoftLayer'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'DedicatedHostManager'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'guests'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'mgr'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'list_guests'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '36', '39', '42', '45', '48', '51']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'host_id'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cpus'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cpu'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'hostname'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'hostname'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'memory'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'memory'}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'formatting'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '75', 'type': 'for_statement', 'children': ['76', '77', '78']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'guest'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'guests'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'add_row'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'list_comprehension', 'children': ['86', '93']}; {'id': '86', 'type': 'boolean_operator', 'children': ['87', '88'], 'value': 'or'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'formatting'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'blank'}; {'id': '92', 'type': 'argument_list', 'children': []}; {'id': '93', 'type': 'for_in_clause', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'guest'}; {'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': 'env'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'fout'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'table'}
|
List guests which are in a dedicated host server.
|
def update_stress_mode(self):
self.stress_conroller.kill_stress_process()
self.view.clock_view.set_text(ZERO_TIME)
self.stress_start_time = timeit.default_timer()
if self.stress_conroller.get_current_mode() == 'Stress':
stress_cmd = self.view.stress_menu.get_stress_cmd()
self.stress_conroller.start_stress(stress_cmd)
elif self.stress_conroller.get_current_mode() == 'FIRESTARTER':
stress_cmd = [self.firestarter]
self.stress_conroller.start_stress(stress_cmd)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_stress_mode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '25', '35']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'stress_conroller'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kill_stress_process'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '23']}; {'id': '16', 'type': 'attribute', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'clock_view'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'set_text'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ZERO_TIME'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'stress_start_time'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'timeit'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'default_timer'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '45', '67']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '44'], 'value': '=='}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'stress_conroller'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get_current_mode'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'string', 'children': [], 'value': "'Stress'"}; {'id': '45', 'type': 'block', 'children': ['46', '58']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'stress_cmd'}; {'id': '49', 'type': 'call', 'children': ['50', '57']}; {'id': '50', 'type': 'attribute', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'stress_menu'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'get_stress_cmd'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'stress_conroller'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'start_stress'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'stress_cmd'}; {'id': '67', 'type': 'elif_clause', 'children': ['68', '77']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '76'], 'value': '=='}; {'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': 'stress_conroller'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_current_mode'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'string', 'children': [], 'value': "'FIRESTARTER'"}; {'id': '77', 'type': 'block', 'children': ['78', '85']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'stress_cmd'}; {'id': '81', 'type': 'list', 'children': ['82'], 'value': '[self.firestarter]'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'firestarter'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '92']}; {'id': '87', 'type': 'attribute', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'stress_conroller'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'start_stress'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'stress_cmd'}
|
Updates stress mode according to radio buttons state
|
def add_broker(self, broker):
if broker not in self._brokers:
self._brokers.add(broker)
else:
self.log.warning(
'Broker {broker_id} already present in '
'replication-group {rg_id}'.format(
broker_id=broker.id,
rg_id=self._id,
)
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_broker'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'broker'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '23']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'not in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'broker'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_brokers'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_brokers'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'broker'}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'concatenated_string', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'Broker {broker_id} already present in '"}; {'id': '37', 'type': 'string', 'children': [], 'value': "'replication-group {rg_id}'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '45']}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'broker_id'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'broker'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'rg_id'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_id'}
|
Add broker to current broker-list.
|
def datetime_to_millis(x):
if x is None:
return None
if hasattr(x, 'timestamp'):
secs = x.timestamp()
elif x.tzinfo is None:
secs = (time.mktime((x.year, x.month, x.day,
x.hour, x.minute, x.second,
-1, -1, -1)) + x.microsecond / 1e6)
else:
secs = (x - _EPOCH).total_seconds()
return int(secs * 1000)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'datetime_to_millis'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '88']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9'], 'value': 'is'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'if_statement', 'children': ['14', '19', '28', '75']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'timestamp'"}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'secs'}; {'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': 'timestamp'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'elif_clause', 'children': ['29', '34']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '33'], 'value': 'is'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tzinfo'}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'secs'}; {'id': '38', 'type': '()', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '70'], 'value': '+'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'mktime'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'tuple', 'children': ['46', '49', '52', '55', '58', '61', '64', '66', '68']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'hour'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'minute'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'second'}; {'id': '64', 'type': 'unary_operator', 'children': ['65'], 'value': '-'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'unary_operator', 'children': ['67'], 'value': '-'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'unary_operator', 'children': ['69'], 'value': '-'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '74'], 'value': '/'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'microsecond'}; {'id': '74', 'type': 'float', 'children': [], 'value': '1e6'}; {'id': '75', 'type': 'else_clause', 'children': ['76']}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'secs'}; {'id': '80', 'type': 'call', 'children': ['81', '87']}; {'id': '81', 'type': 'attribute', 'children': ['82', '86']}; {'id': '82', 'type': '()', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '-'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': '_EPOCH'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'total_seconds'}; {'id': '87', 'type': 'argument_list', 'children': []}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '94'], 'value': '*'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'secs'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '1000'}
|
Convert a `datetime.datetime` to milliseconds since the epoch
|
def render_in_page(request, template):
from leonardo.module.web.models import Page
page = request.leonardo_page if hasattr(
request, 'leonardo_page') else Page.objects.filter(parent=None).first()
if page:
try:
slug = request.path_info.split("/")[-2:-1][0]
except KeyError:
slug = None
try:
body = render_to_string(template, RequestContext(request, {
'request_path': request.path,
'feincms_page': page,
'slug': slug,
'standalone': True}))
response = http.HttpResponseNotFound(
body, content_type=CONTENT_TYPE)
except TemplateDoesNotExist:
response = False
return response
return False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_in_page'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '41', '122']}; {'id': '7', 'type': 'import_from_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'dotted_name', 'children': ['9', '10', '11', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'leonardo'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'web'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Page'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '18', 'type': 'conditional_expression', 'children': ['19', '22', '27'], 'value': 'if'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'leonardo_page'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'leonardo_page'"}; {'id': '27', 'type': 'call', 'children': ['28', '40']}; {'id': '28', 'type': 'attribute', 'children': ['29', '39']}; {'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': 'Page'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'if_statement', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '43', 'type': 'block', 'children': ['44', '73', '120']}; {'id': '44', 'type': 'try_statement', 'children': ['45', '66']}; {'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': 'slug'}; {'id': '49', 'type': 'subscript', 'children': ['50', '65']}; {'id': '50', 'type': 'subscript', 'children': ['51', '59']}; {'id': '51', 'type': 'call', 'children': ['52', '57']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'path_info'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '59', 'type': 'slice', 'children': ['60', '62', '63']}; {'id': '60', 'type': 'unary_operator', 'children': ['61'], 'value': '-'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '62', 'type': 'colon', 'children': []}; {'id': '63', 'type': 'unary_operator', 'children': ['64'], 'value': '-'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'except_clause', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'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': 'slug'}; {'id': '72', 'type': 'None', 'children': []}; {'id': '73', 'type': 'try_statement', 'children': ['74', '113']}; {'id': '74', 'type': 'block', 'children': ['75', '101']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'render_to_string'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'RequestContext'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '86', 'type': 'dictionary', 'children': ['87', '92', '95', '98']}; {'id': '87', 'type': 'pair', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': "'request_path'"}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '92', 'type': 'pair', 'children': ['93', '94']}; {'id': '93', 'type': 'string', 'children': [], 'value': "'feincms_page'"}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '95', 'type': 'pair', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': "'slug'"}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'slug'}; {'id': '98', 'type': 'pair', 'children': ['99', '100']}; {'id': '99', 'type': 'string', 'children': [], 'value': "'standalone'"}; {'id': '100', 'type': 'True', 'children': []}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'http'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'HttpResponseNotFound'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'CONTENT_TYPE'}; {'id': '113', 'type': 'except_clause', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'TemplateDoesNotExist'}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '119', 'type': 'False', 'children': []}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '122', 'type': 'return_statement', 'children': ['123']}; {'id': '123', 'type': 'False', 'children': []}
|
return rendered template in standalone mode or ``False``
|
def resources(self):
return [self.pdf.getPage(i) for i in range(self.pdf.getNumPages())]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resources'}; {'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': 'list_comprehension', 'children': ['8', '16']}; {'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': 'pdf'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'getPage'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '16', 'type': 'for_in_clause', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'pdf'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'getNumPages'}; {'id': '27', 'type': 'argument_list', 'children': []}
|
Retrieve contents of each page of PDF
|
def _mds_rpc_post(self, device_id, _wrap_with_consumer=True, async_id=None, **params):
self.ensure_notifications_thread()
api = self._get_api(mds.DeviceRequestsApi)
async_id = async_id or utils.new_async_id()
device_request = mds.DeviceRequest(**params)
api.create_async_request(
device_id,
async_id=async_id,
body=device_request,
)
return AsyncConsumer(async_id, self._db) if _wrap_with_consumer else async_id
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_mds_rpc_post'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'device_id'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': '_wrap_with_consumer'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'async_id'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'dictionary_splat_pattern', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '14', 'type': 'block', 'children': ['15', '21', '32', '42', '52', '65']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ensure_notifications_thread'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_get_api'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'mds'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'DeviceRequestsApi'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'async_id'}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '37'], 'value': 'or'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'async_id'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'new_async_id'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'device_request'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'mds'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'DeviceRequest'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'dictionary_splat', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'create_async_request'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59', '62']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'device_id'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'async_id'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'async_id'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'device_request'}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'conditional_expression', 'children': ['67', '74', '75'], 'value': 'if'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'AsyncConsumer'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'async_id'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_db'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_wrap_with_consumer'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'async_id'}
|
Helper for using RPC endpoint
|
def move_to_next_bit_address(self):
self._current_bit_address = self.next_bit_address()
self.mark_address(self._current_bit_address.split('.')[0], self._size_of_current_register_address)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move_to_next_bit_address'}; {'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': '_current_bit_address'}; {'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': 'next_bit_address'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'mark_address'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '32']}; {'id': '22', 'type': 'subscript', 'children': ['23', '31']}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_current_bit_address'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_size_of_current_register_address'}
|
Moves to next available bit address position
|
def upload(self, path, engine, description=None):
if description is None:
head, tail = ntpath.split(path)
description = tail or ntpath.basename(head)
url = "http://quickslice.{}/config/raw/".format(self.config.host)
with open(path) as config_file:
content = config_file.read()
payload = {"engine": engine,
"description": description,
"content": content}
post_resp = requests.post(url, json=payload, cookies={"session": self.session})
if not post_resp.ok:
raise errors.ResourceError("config upload to slicing service failed")
self.description = description
self.location = post_resp.headers["Location"]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '38', '51', '70', '83', '103', '116', '122']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16', '27']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'pattern_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'tail'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ntpath'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '32'], 'value': 'or'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tail'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ntpath'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"http://quickslice.{}/config/raw/"'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'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': 'config'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '51', 'type': 'with_statement', 'children': ['52', '61']}; {'id': '52', 'type': 'with_clause', 'children': ['53']}; {'id': '53', 'type': 'with_item', 'children': ['54']}; {'id': '54', 'type': 'as_pattern', 'children': ['55', '59']}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '59', 'type': 'as_pattern_target', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'config_file'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'config_file'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '73', 'type': 'dictionary', 'children': ['74', '77', '80']}; {'id': '74', 'type': 'pair', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"engine"'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '77', 'type': 'pair', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': '"description"'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '80', 'type': 'pair', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': '"content"'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'post_resp'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92', '95']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '92', 'type': 'keyword_argument', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '95', 'type': 'keyword_argument', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'cookies'}; {'id': '97', 'type': 'dictionary', 'children': ['98']}; {'id': '98', 'type': 'pair', 'children': ['99', '100']}; {'id': '99', 'type': 'string', 'children': [], 'value': '"session"'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '103', 'type': 'if_statement', 'children': ['104', '108']}; {'id': '104', 'type': 'not_operator', 'children': ['105']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'post_resp'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'ok'}; {'id': '108', 'type': 'block', 'children': ['109']}; {'id': '109', 'type': 'raise_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ResourceError'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'string', 'children': [], 'value': '"config upload to slicing service failed"'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '127', 'type': 'subscript', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'post_resp'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '131', 'type': 'string', 'children': [], 'value': '"Location"'}
|
Create a new config resource in the slicing service and upload the path contents to it
|
def extract_pdftotext(self, filename, **kwargs):
if 'layout' in kwargs:
args = ['pdftotext', '-layout', filename, '-']
else:
args = ['pdftotext', filename, '-']
stdout, _ = self.run(args)
return stdout
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_pdftotext'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '31', '42']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13', '22']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'in'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'layout'"}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '17', 'type': 'list', 'children': ['18', '19', '20', '21'], 'value': "['pdftotext', '-layout', filename, '-']"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'pdftotext'"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'-layout'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '22', 'type': 'else_clause', 'children': ['23']}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '27', 'type': 'list', 'children': ['28', '29', '30'], 'value': "['pdftotext', filename, '-']"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'pdftotext'"}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'pattern_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'stdout'}
|
Extract text from pdfs using the pdftotext command line utility.
|
def loc_info(text, index):
if index > len(text):
raise ValueError('Invalid index.')
line, last_ln = text.count('\n', 0, index), text.rfind('\n', 0, index)
col = index - (last_ln + 1)
return (line, col)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'loc_info'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '42', '51']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '>'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'Invalid index.'"}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'last_ln'}; {'id': '25', 'type': 'expression_list', 'children': ['26', '34']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'rfind'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40', '41']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '-'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '47', 'type': '()', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '+'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'last_ln'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'tuple', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'col'}
|
Location of `index` in source code `text`.
|
def instruction_ASR_register(self, opcode, register):
a = register.value
r = self.ASR(a)
register.set(r)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'instruction_ASR_register'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'opcode'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '23']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'r'}; {'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': 'ASR'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'r'}
|
Arithmetic shift accumulator right
|
def clean_text(text):
if text:
text = html2text.html2text(clean_markdown(text))
return re.sub(r'\s+', ' ', text).strip()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_text'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '8', 'type': 'block', 'children': ['9', '21']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'html2text'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'html2text'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'clean_markdown'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '33']}; {'id': '23', 'type': 'attribute', 'children': ['24', '32']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '31']}; {'id': '29', 'type': 'string', 'children': [], 'value': "r'\\s+'"}; {'id': '30', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '33', 'type': 'argument_list', 'children': []}
|
Retrieve clean text without markdown sintax or other things.
|
def rename_column(self, model, old_name, new_name):
field = model._meta.fields[old_name]
if isinstance(field, pw.ForeignKeyField):
old_name = field.column_name
self.__del_field__(model, field)
field.name = field.column_name = new_name
model._meta.add_field(new_name, field)
if isinstance(field, pw.ForeignKeyField):
field.column_name = new_name = field.column_name + '_id'
self.ops.append(self.migrator.rename_column(model._meta.table_name, old_name, new_name))
return model
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rename_column'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'old_name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'new_name'}; {'id': '8', 'type': 'block', 'children': ['9', '19', '34', '42', '52', '62', '83', '105']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '12', 'type': 'subscript', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'old_name'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '27']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'pw'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ForeignKeyField'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'old_name'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'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': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__del_field__'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '47', 'type': 'assignment', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'new_name'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'add_field'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'new_name'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '62', 'type': 'if_statement', 'children': ['63', '70']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'pw'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ForeignKeyField'}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'new_name'}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '82'], 'value': '+'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'_id'"}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '90']}; {'id': '85', 'type': 'attribute', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '97']}; {'id': '92', 'type': 'attribute', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'migrator'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'rename_column'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '103', '104']}; {'id': '98', 'type': 'attribute', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'table_name'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'old_name'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'new_name'}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'model'}
|
Rename field in model.
|
def titleify(self, lang='en', allwords=False, lastword=True):
if lang in LOWERCASE_WORDS:
lc_words = LOWERCASE_WORDS[lang]
else:
lc_words = []
s = str(self).strip()
l = re.split(r"([_\W]+)", s)
for i in range(len(l)):
l[i] = l[i].lower()
if (
allwords == True
or i == 0
or (lastword == True and i == len(l) - 1)
or l[i].lower() not in lc_words
):
w = l[i]
if len(w) > 1:
w = w[0].upper() + w[1:]
else:
w = w.upper()
l[i] = w
s = "".join(l)
return String(s)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'titleify'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lang'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'en'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'allwords'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'lastword'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '32', '43', '53', '155', '164']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19', '26']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'in'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'lang'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'LOWERCASE_WORDS'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'lc_words'}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'LOWERCASE_WORDS'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'lang'}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'lc_words'}; {'id': '31', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '35', 'type': 'call', 'children': ['36', '42']}; {'id': '36', 'type': 'attribute', 'children': ['37', '41']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': 'r"([_\\W]+)"'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '62']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '62', 'type': 'block', 'children': ['63', '75']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'if_statement', 'children': ['76', '108']}; {'id': '76', 'type': '()', 'children': ['77']}; {'id': '77', 'type': 'boolean_operator', 'children': ['78', '99'], 'value': 'or'}; {'id': '78', 'type': 'boolean_operator', 'children': ['79', '86'], 'value': 'or'}; {'id': '79', 'type': 'boolean_operator', 'children': ['80', '83'], 'value': 'or'}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': '=='}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'allwords'}; {'id': '82', 'type': 'True', 'children': []}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '85'], 'value': '=='}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '86', 'type': '()', 'children': ['87']}; {'id': '87', 'type': 'boolean_operator', 'children': ['88', '91'], 'value': 'and'}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '90'], 'value': '=='}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'lastword'}; {'id': '90', 'type': 'True', 'children': []}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': '=='}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '98'], 'value': '-'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '107'], 'value': 'not in'}; {'id': '100', 'type': 'call', 'children': ['101', '106']}; {'id': '101', 'type': 'attribute', 'children': ['102', '105']}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '106', 'type': 'argument_list', 'children': []}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'lc_words'}; {'id': '108', 'type': 'block', 'children': ['109', '115', '149']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '112', 'type': 'subscript', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '115', 'type': 'if_statement', 'children': ['116', '122', '139']}; {'id': '116', 'type': 'comparison_operator', 'children': ['117', '121'], 'value': '>'}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '121', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '126', 'type': 'binary_operator', 'children': ['127', '134'], 'value': '+'}; {'id': '127', 'type': 'call', 'children': ['128', '133']}; {'id': '128', 'type': 'attribute', 'children': ['129', '132']}; {'id': '129', 'type': 'subscript', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '131', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '133', 'type': 'argument_list', 'children': []}; {'id': '134', 'type': 'subscript', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '136', 'type': 'slice', 'children': ['137', '138']}; {'id': '137', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '138', 'type': 'colon', 'children': []}; {'id': '139', 'type': 'else_clause', 'children': ['140']}; {'id': '140', 'type': 'block', 'children': ['141']}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '144', 'type': 'call', 'children': ['145', '148']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '148', 'type': 'argument_list', 'children': []}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '154']}; {'id': '151', 'type': 'subscript', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'assignment', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '158', 'type': 'call', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'string', 'children': [], 'value': '""'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '164', 'type': 'return_statement', 'children': ['165']}; {'id': '165', 'type': 'call', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'String'}; {'id': '167', 'type': 'argument_list', 'children': ['168']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 's'}
|
takes a string and makes a title from it
|
def compile_rich(cls, code, path=None, extra_args=None):
return {
contract_name: {
'code': '0x' + contract.get('bin_hex'),
'info': {
'abiDefinition': contract.get('abi'),
'compilerVersion': cls.compiler_version(),
'developerDoc': contract.get('devdoc'),
'language': 'Solidity',
'languageVersion': '0',
'source': code,
'userDoc': contract.get('userdoc')
},
}
for contract_name, contract
in cls.combined(code, path=path, extra_args=extra_args)
}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compile_rich'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'extra_args'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'dictionary_comprehension', 'children': ['15', '71']}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'contract_name'}; {'id': '17', 'type': 'dictionary', 'children': ['18', '28']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'code'"}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '+'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'0x'"}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'contract'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'bin_hex'"}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'info'"}; {'id': '30', 'type': 'dictionary', 'children': ['31', '39', '46', '54', '57', '60', '63']}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'abiDefinition'"}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'contract'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'abi'"}; {'id': '39', 'type': 'pair', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'compilerVersion'"}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'compiler_version'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'pair', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'developerDoc'"}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'contract'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'devdoc'"}; {'id': '54', 'type': 'pair', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'language'"}; {'id': '56', 'type': 'string', 'children': [], 'value': "'Solidity'"}; {'id': '57', 'type': 'pair', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'languageVersion'"}; {'id': '59', 'type': 'string', 'children': [], 'value': "'0'"}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'source'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '63', 'type': 'pair', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'userDoc'"}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'contract'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'userdoc'"}; {'id': '71', 'type': 'for_in_clause', 'children': ['72', '75']}; {'id': '72', 'type': 'pattern_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'contract_name'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'contract'}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81', '84']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'extra_args'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'extra_args'}
|
full format as returned by jsonrpc
|
def _process_locale(self, locale):
if locale.lower().startswith('en'):
return False
return (locale in self.enabled_locales or
self.reverse_locale_map.get(locale.lower(), None)
in self.enabled_locales or
locale in self.lower_locales or
self.reverse_locale_map.get(locale.lower(), None)
in self.lower_locales
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_locale'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '6', 'type': 'block', 'children': ['7', '21']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'call', 'children': ['9', '16']}; {'id': '9', 'type': 'attribute', 'children': ['10', '15']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'en'"}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'False', 'children': []}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': '()', 'children': ['23']}; {'id': '23', 'type': 'boolean_operator', 'children': ['24', '53'], 'value': 'or'}; {'id': '24', 'type': 'boolean_operator', 'children': ['25', '48'], 'value': 'or'}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '31'], 'value': 'or'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'in'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'enabled_locales'}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '45'], 'value': 'in'}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'reverse_locale_map'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '44']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'enabled_locales'}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'in'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'lower_locales'}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '67'], 'value': 'in'}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'reverse_locale_map'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '66']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'locale'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '65', 'type': 'argument_list', 'children': []}; {'id': '66', 'type': 'None', 'children': []}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'lower_locales'}
|
Return True if this locale should be processed.
|
def get(path):
try:
import cPickle as pickle
except:
import pickle
with open(path, 'rb') as file:
return pickle.load(file)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6', '18']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'import_statement', 'children': ['9']}; {'id': '9', 'type': 'aliased_import', 'children': ['10', '12']}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cPickle'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '13', 'type': 'except_clause', 'children': ['14']}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'import_statement', 'children': ['16']}; {'id': '16', 'type': 'dotted_name', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '18', 'type': 'with_statement', 'children': ['19', '29']}; {'id': '19', 'type': 'with_clause', 'children': ['20']}; {'id': '20', 'type': 'with_item', 'children': ['21']}; {'id': '21', 'type': 'as_pattern', 'children': ['22', '27']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '27', 'type': 'as_pattern_target', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'file'}
|
Read an object from file
|
def _parse_head(heads, head_grads):
if isinstance(heads, NDArray):
heads = [heads]
if isinstance(head_grads, NDArray):
head_grads = [head_grads]
head_handles = c_handle_array(heads)
if head_grads is None:
hgrad_handles = ctypes.c_void_p(0)
else:
assert len(heads) == len(head_grads), \
"heads and head_grads must be lists of the same length"
hgrad_handles = c_array(NDArrayHandle,
[i.handle if i is not None else NDArrayHandle(0)
for i in head_grads])
return head_handles, hgrad_handles
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_head'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'heads'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'head_grads'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '31', '38', '87']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'heads'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'NDArray'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'heads'}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': '[heads]'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'heads'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '25']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'head_grads'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'NDArray'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'head_grads'}; {'id': '29', 'type': 'list', 'children': ['30'], 'value': '[head_grads]'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'head_grads'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'head_handles'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'c_handle_array'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'heads'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '42', '52']}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '41'], 'value': 'is'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'head_grads'}; {'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': 'hgrad_handles'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'c_void_p'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'else_clause', 'children': ['53']}; {'id': '53', 'type': 'block', 'children': ['54', '65']}; {'id': '54', 'type': 'assert_statement', 'children': ['55', '64']}; {'id': '55', 'type': 'comparison_operator', 'children': ['56', '60'], 'value': '=='}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'heads'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'head_grads'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"heads and head_grads must be lists of the same length"'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'hgrad_handles'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'c_array'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'NDArrayHandle'}; {'id': '72', 'type': 'list_comprehension', 'children': ['73', '84']}; {'id': '73', 'type': 'conditional_expression', 'children': ['74', '77', '80'], 'value': 'if'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '79'], 'value': 'is not'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '79', 'type': 'None', 'children': []}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'NDArrayHandle'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '84', 'type': 'for_in_clause', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'head_grads'}; {'id': '87', 'type': 'return_statement', 'children': ['88']}; {'id': '88', 'type': 'expression_list', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'head_handles'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'hgrad_handles'}
|
parse head gradient for backward and grad.
|
def convert_to_python(self, xmlrpc=None):
if xmlrpc:
return xmlrpc.get(self.name, self.default)
elif self.default:
return self.default
else:
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_to_python'}; {'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': 'xmlrpc'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '11', '24', '33']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'xmlrpc'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'xmlrpc'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '24', 'type': 'elif_clause', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '33', 'type': 'else_clause', 'children': ['34']}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'None', 'children': []}
|
Extracts a value for the field from an XML-RPC response.
|
def check_is_a_sequence(var, allow_none=False):
if not is_a_sequence(var, allow_none=allow_none):
raise TypeError("var must be a list or tuple, however type(var) is {}"
.format(type(var)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_is_a_sequence'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'allow_none'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '18']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'is_a_sequence'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'allow_none'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'allow_none'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'raise_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"var must be a list or tuple, however type(var) is {}"'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'var'}
|
Calls is_a_sequence and raises a type error if the check fails.
|
def orphans(dburl, sitedir):
oldcwd = os.getcwd()
os.chdir(sitedir)
db = StrictRedis.from_url(dburl)
job = get_current_job(db)
job.meta.update({'out': '', 'return': None, 'status': None})
job.save()
returncode, out = orphans_single(default_exec=True)
job.meta.update({'out': out, 'return': returncode, 'status':
returncode == 0})
job.save()
os.chdir(oldcwd)
return returncode
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'orphans'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dburl'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sitedir'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '22', '31', '38', '56', '62', '73', '93', '99', '106']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'oldcwd'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sitedir'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'StrictRedis'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'from_url'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'dburl'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'get_current_job'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'dictionary', 'children': ['47', '50', '53']}; {'id': '47', 'type': 'pair', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '49', 'type': 'string', 'children': [], 'value': "''"}; {'id': '50', 'type': 'pair', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'return'"}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'pair', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '67']}; {'id': '64', 'type': 'pattern_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'orphans_single'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'default_exec'}; {'id': '72', 'type': 'True', 'children': []}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '80']}; {'id': '75', 'type': 'attribute', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'dictionary', 'children': ['82', '85', '88']}; {'id': '82', 'type': 'pair', 'children': ['83', '84']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '85', 'type': 'pair', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'return'"}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '88', 'type': 'pair', 'children': ['89', '90']}; {'id': '89', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '92'], 'value': '=='}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'returncode'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'job'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '98', 'type': 'argument_list', 'children': []}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'oldcwd'}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'returncode'}
|
Remove all orphans in the site.
|
def compute(self, today, assets, out, *arrays):
raise NotImplementedError(
"{name} must define a compute method".format(
name=type(self).__name__
)
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'assets'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '8', 'type': 'list_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'arrays'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'raise_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'NotImplementedError'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"{name} must define a compute method"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'attribute', 'children': ['23', '27']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '__name__'}
|
Override this method with a function that writes a value into `out`.
|
def _get_template(querystring_key, mapping):
default = None
try:
template_and_keys = mapping.items()
except AttributeError:
template_and_keys = mapping
for template, key in template_and_keys:
if key is None:
key = PAGE_LABEL
default = template
if key == querystring_key:
return template
return default
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_template'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'querystring_key'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '28', '54']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'try_statement', 'children': ['12', '21']}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'template_and_keys'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'except_clause', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'template_and_keys'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'mapping'}; {'id': '28', 'type': 'for_statement', 'children': ['29', '32', '33']}; {'id': '29', 'type': 'pattern_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'template_and_keys'}; {'id': '33', 'type': 'block', 'children': ['34', '47']}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'is'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39', '43']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'PAGE_LABEL'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '51']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': '=='}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'querystring_key'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'default'}
|
Return the template corresponding to the given ``querystring_key``.
|
def apply_mana_drain(self):
self.r = self.g = self.b = self.y = 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply_mana_drain'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'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': 'r'}; {'id': '11', 'type': 'assignment', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}
|
Clear current mana values.
|
def description(self):
if 'metrics' in self.raw:
metrics = self.raw['metrics']
head = metrics[0:-1] or metrics[0:1]
text = ", ".join(head)
if len(metrics) > 1:
tail = metrics[-1]
text = text + " and " + tail
else:
text = 'n/a'
return text
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'description'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '76']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '70']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9'], 'value': 'in'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'metrics'"}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '12', 'type': 'block', 'children': ['13', '21', '38', '47']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '16', 'type': 'subscript', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'metrics'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '24', 'type': 'boolean_operator', 'children': ['25', '32'], 'value': 'or'}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '27', 'type': 'slice', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'colon', 'children': []}; {'id': '30', 'type': 'unary_operator', 'children': ['31'], 'value': '-'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '34', 'type': 'slice', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'colon', 'children': []}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '54']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '53'], 'value': '>'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'block', 'children': ['55', '62']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'tail'}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '60', 'type': 'unary_operator', 'children': ['61'], 'value': '-'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '69'], 'value': '+'}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '68'], 'value': '+'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '68', 'type': 'string', 'children': [], 'value': '" and "'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'tail'}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'n/a'"}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'text'}
|
A list of the metrics this query will ask for.
|
def cli(env, sortby, datacenter):
block_manager = SoftLayer.BlockStorageManager(env.client)
mask = "mask[serviceResource[datacenter[name]],"\
"replicationPartners[serviceResource[datacenter[name]]]]"
block_volumes = block_manager.list_block_volumes(datacenter=datacenter,
mask=mask)
datacenters = dict()
for volume in block_volumes:
service_resource = volume['serviceResource']
if 'datacenter' in service_resource:
datacenter_name = service_resource['datacenter']['name']
if datacenter_name not in datacenters.keys():
datacenters[datacenter_name] = 1
else:
datacenters[datacenter_name] += 1
table = formatting.KeyValueTable(DEFAULT_COLUMNS)
table.sortby = sortby
for datacenter_name in datacenters:
table.add_row([datacenter_name, datacenters[datacenter_name]])
env.fout(table)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'datacenter'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '25', '39', '45', '91', '100', '106', '121']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'block_manager'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'SoftLayer'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'BlockStorageManager'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '22', 'type': 'concatenated_string', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"mask[serviceResource[datacenter[name]],"'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"replicationPartners[serviceResource[datacenter[name]]]]"'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'block_volumes'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'block_manager'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'list_block_volumes'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '36']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'datacenter'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'datacenter'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'datacenters'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'for_statement', 'children': ['46', '47', '48']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'block_volumes'}; {'id': '48', 'type': 'block', 'children': ['49', '55']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'service_resource'}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'volume'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'serviceResource'"}; {'id': '55', 'type': 'if_statement', 'children': ['56', '59']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'in'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'datacenter'"}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'service_resource'}; {'id': '59', 'type': 'block', 'children': ['60', '68']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'datacenter_name'}; {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'subscript', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'service_resource'}; {'id': '66', 'type': 'string', 'children': [], 'value': "'datacenter'"}; {'id': '67', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '68', 'type': 'if_statement', 'children': ['69', '76', '83']}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71'], 'value': 'not in'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'datacenter_name'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'datacenters'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '82']}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'datacenters'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'datacenter_name'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'else_clause', 'children': ['84']}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'augmented_assignment', 'children': ['87', '90'], 'value': '+='}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'datacenters'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'datacenter_name'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'formatting'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'KeyValueTable'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_COLUMNS'}; {'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': 'table'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '106', 'type': 'for_statement', 'children': ['107', '108', '109']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'datacenter_name'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'datacenters'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'add_row'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'list', 'children': ['117', '118'], 'value': '[datacenter_name, datacenters[datacenter_name]]'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'datacenter_name'}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'datacenters'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'datacenter_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': 'env'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'fout'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'table'}
|
List number of block storage volumes per datacenter.
|
def blur(self):
self._has_focus = False
try:
self._columns[self._live_col][self._live_widget].blur()
except IndexError:
pass
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'blur'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_has_focus'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'try_statement', 'children': ['13', '30']}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '29']}; {'id': '16', 'type': 'attribute', 'children': ['17', '28']}; {'id': '17', 'type': 'subscript', 'children': ['18', '25']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_columns'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_live_col'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_live_widget'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'blur'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'except_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'pass_statement', 'children': []}
|
Call this to take the input focus from this Layout.
|
def provide_with_default(self, name, default=None):
return self.provider.instantiate_by_name_with_default(name, default_value=default)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'provide_with_default'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'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': 'provider'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'instantiate_by_name_with_default'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'default_value'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'default'}
|
Return a dependency-injected instance
|
def _get_table_info(self):
self.fields = []
self.field_info = {}
self.cursor.execute('PRAGMA table_info (%s)' %self.name)
for field_info in self.cursor.fetchall():
fname = field_info[1].encode('utf-8')
self.fields.append(fname)
ftype = field_info[2].encode('utf-8')
info = {'type':ftype}
info['NOT NULL'] = field_info[3] != 0
default = field_info[4]
if isinstance(default,unicode):
default = guess_default_fmt(default)
info['DEFAULT'] = default
self.field_info[fname] = info
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_table_info'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '31']}; {'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': 'fields'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'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': 'field_info'}; {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '28'], 'value': '%'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'PRAGMA table_info (%s)'"}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '40']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'field_info'}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fetchall'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41', '52', '61', '72', '79', '89', '95', '109', '115']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'field_info'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '59']}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '64', 'type': 'call', 'children': ['65', '70']}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'field_info'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '75', 'type': 'dictionary', 'children': ['76']}; {'id': '76', 'type': 'pair', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '84']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '83', 'type': 'string', 'children': [], 'value': "'NOT NULL'"}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '88'], 'value': '!='}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'field_info'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'field_info'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '95', 'type': 'if_statement', 'children': ['96', '101']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'guess_default_fmt'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '114']}; {'id': '111', 'type': 'subscript', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '113', 'type': 'string', 'children': [], 'value': "'DEFAULT'"}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '122']}; {'id': '117', 'type': 'subscript', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'field_info'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'info'}
|
Inspect the base to get field names
|
def _compute_centers(self, X, sparse, rs):
super(GRBFRandomLayer, self)._compute_centers(X, sparse, rs)
centers = self.components_['centers']
sorted_distances = np.sort(squareform(pdist(centers)))
self.dF_vals = sorted_distances[:, -1]
self.dN_vals = sorted_distances[:, 1]/100.0
tauNum = np.log(np.log(self.grbf_lambda) /
np.log(1.0 - self.grbf_lambda))
tauDenom = np.log(self.dF_vals/self.dN_vals)
self.tau_vals = tauNum/tauDenom
self._extra_args['taus'] = self.tau_vals
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_compute_centers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sparse'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'rs'}; {'id': '8', 'type': 'block', 'children': ['9', '22', '30', '45', '56', '68', '95', '110', '118']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '18']}; {'id': '11', 'type': 'attribute', 'children': ['12', '17']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'GRBFRandomLayer'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_compute_centers'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sparse'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rs'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'centers'}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'components_'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'centers'"}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sorted_distances'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'squareform'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pdist'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'centers'}; {'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': 'dF_vals'}; {'id': '50', 'type': 'subscript', 'children': ['51', '52', '54']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sorted_distances'}; {'id': '52', 'type': 'slice', 'children': ['53']}; {'id': '53', 'type': 'colon', 'children': []}; {'id': '54', 'type': 'unary_operator', 'children': ['55'], 'value': '-'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dN_vals'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '67'], 'value': '/'}; {'id': '62', 'type': 'subscript', 'children': ['63', '64', '66']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'sorted_distances'}; {'id': '64', 'type': 'slice', 'children': ['65']}; {'id': '65', 'type': 'colon', 'children': []}; {'id': '66', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '67', 'type': 'float', 'children': [], 'value': '100.0'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'tauNum'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '85'], 'value': '/'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'grbf_lambda'}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '92'], 'value': '-'}; {'id': '91', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'grbf_lambda'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'tauDenom'}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'binary_operator', 'children': ['104', '107'], 'value': '/'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'dF_vals'}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'dN_vals'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'tau_vals'}; {'id': '115', 'type': 'binary_operator', 'children': ['116', '117'], 'value': '/'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'tauNum'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'tauDenom'}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'assignment', 'children': ['120', '125']}; {'id': '120', 'type': 'subscript', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': '_extra_args'}; {'id': '124', 'type': 'string', 'children': [], 'value': "'taus'"}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'tau_vals'}
|
Generate centers, then compute tau, dF and dN vals
|
def move(self, new_father, idx=None, prepend=None, name=None):
self.parent.pop(self._own_index)
new_father._insert(self, idx=idx, prepend=prepend, name=name)
new_father._stable = False
return self
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'new_father'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'prepend'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16', '27', '43', '49']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'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': '_own_index'}; {'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': 'new_father'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_insert'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '37', '40']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'prepend'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'prepend'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'new_father'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_stable'}; {'id': '48', 'type': 'False', 'children': []}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}
|
Moves this element from his father to the given one.
|
def parse(self, **kwargs):
try:
output_folder = self.retrieved
except exceptions.NotExistent:
return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER
filename_stdout = self.node.get_attribute('output_filename')
filename_stderr = self.node.get_attribute('error_filename')
try:
with output_folder.open(filename_stderr, 'r') as handle:
exit_code = self.parse_stderr(handle)
except (OSError, IOError):
self.logger.exception('Failed to read the stderr file\n%s', traceback.format_exc())
return self.exit_codes.ERROR_READING_ERROR_FILE
if exit_code:
return exit_code
try:
with output_folder.open(filename_stdout, 'r') as handle:
handle.seek(0)
exit_code = self.parse_stdout(handle)
except (OSError, IOError):
self.logger.exception('Failed to read the stdout file\n%s', traceback.format_exc())
return self.exit_codes.ERROR_READING_OUTPUT_FILE
if exit_code:
return exit_code
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}; {'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', '27', '38', '49', '99', '104', '161']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '16']}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'output_folder'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'retrieved'}; {'id': '16', 'type': 'except_clause', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'NotExistent'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'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': 'exit_codes'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ERROR_NO_RETRIEVED_FOLDER'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'filename_stdout'}; {'id': '30', 'type': 'call', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'get_attribute'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'output_filename'"}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'filename_stderr'}; {'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': 'node'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'get_attribute'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'error_filename'"}; {'id': '49', 'type': 'try_statement', 'children': ['50', '74']}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'with_statement', 'children': ['52', '64']}; {'id': '52', 'type': 'with_clause', 'children': ['53']}; {'id': '53', 'type': 'with_item', 'children': ['54']}; {'id': '54', 'type': 'as_pattern', 'children': ['55', '62']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'output_folder'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'filename_stderr'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '62', 'type': 'as_pattern_target', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'exit_code'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'parse_stderr'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '74', 'type': 'except_clause', 'children': ['75', '78']}; {'id': '75', 'type': 'tuple', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '78', 'type': 'block', 'children': ['79', '93']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'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': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'string', 'children': [], 'value': "'Failed to read the stderr file\\n%s'"}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'format_exc'}; {'id': '92', 'type': 'argument_list', 'children': []}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'exit_codes'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ERROR_READING_ERROR_FILE'}; {'id': '99', 'type': 'if_statement', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'exit_code'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'exit_code'}; {'id': '104', 'type': 'try_statement', 'children': ['105', '136']}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'with_statement', 'children': ['107', '119']}; {'id': '107', 'type': 'with_clause', 'children': ['108']}; {'id': '108', 'type': 'with_item', 'children': ['109']}; {'id': '109', 'type': 'as_pattern', 'children': ['110', '117']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'output_folder'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'filename_stdout'}; {'id': '116', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '117', 'type': 'as_pattern_target', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '119', 'type': 'block', 'children': ['120', '127']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'call', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '125', 'type': 'argument_list', 'children': ['126']}; {'id': '126', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'exit_code'}; {'id': '130', 'type': 'call', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'parse_stdout'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '136', 'type': 'except_clause', 'children': ['137', '140']}; {'id': '137', 'type': 'tuple', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '140', 'type': 'block', 'children': ['141', '155']}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'call', 'children': ['143', '148']}; {'id': '143', 'type': 'attribute', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '148', 'type': 'argument_list', 'children': ['149', '150']}; {'id': '149', 'type': 'string', 'children': [], 'value': "'Failed to read the stdout file\\n%s'"}; {'id': '150', 'type': 'call', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'format_exc'}; {'id': '154', 'type': 'argument_list', 'children': []}; {'id': '155', 'type': 'return_statement', 'children': ['156']}; {'id': '156', 'type': 'attribute', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'exit_codes'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'ERROR_READING_OUTPUT_FILE'}; {'id': '161', 'type': 'if_statement', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'exit_code'}; {'id': '163', 'type': 'block', 'children': ['164']}; {'id': '164', 'type': 'return_statement', 'children': ['165']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'exit_code'}
|
Parse the contents of the output files retrieved in the `FolderData`.
|
def cache_keys(keys):
d = known_keys()
known_names = dict(zip(d.values(), d.keys()))
for k in keys:
i = (ord(k),) if len(k) == 1 else known_names[k]
_key_cache.insert(0, i)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cache_keys'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '31']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'known_keys'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'known_names'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '26']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '34', 'type': 'block', 'children': ['35', '53']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '38', 'type': 'conditional_expression', 'children': ['39', '44', '50'], 'value': 'if'}; {'id': '39', 'type': 'tuple', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ord'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '49'], 'value': '=='}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'known_names'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_key_cache'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'i'}
|
Allow debugging via PyCharm
|
def load(self, name):
name = ctypes.util.find_library(name)
return ctypes.cdll.LoadLibrary(name)
|
{'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': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '18']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'find_library'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cdll'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'LoadLibrary'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}
|
Loads and returns foreign library.
|
def new_text_block(self, **kwargs):
proto = {'content': '', 'type': self.markdown}
proto.update(**kwargs)
return proto
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'new_text_block'}; {'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', '20', '28']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'proto'}; {'id': '11', 'type': 'dictionary', 'children': ['12', '15']}; {'id': '12', 'type': 'pair', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'content'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "''"}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'markdown'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'proto'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'dictionary_splat', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'proto'}
|
Create a new text block.
|
def _where(filename, dirs=[], env="PATH"):
if not isinstance(dirs, list):
dirs = [dirs]
if glob(filename):
return filename
paths = [os.curdir] + os.environ[env].split(os.path.pathsep) + dirs
for path in paths:
for match in glob(os.path.join(path, filename)):
if match:
return os.path.normpath(match)
raise IOError("File not found: %s" % filename)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_where'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '7', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"PATH"'}; {'id': '11', 'type': 'block', 'children': ['12', '25', '33', '57', '88']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '19']}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '23', 'type': 'list', 'children': ['24'], 'value': '[dirs]'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '30']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '56'], 'value': '+'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '42'], 'value': '+'}; {'id': '38', 'type': 'list', 'children': ['39'], 'value': '[os.curdir]'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'curdir'}; {'id': '42', 'type': 'call', 'children': ['43', '50']}; {'id': '43', 'type': 'attribute', 'children': ['44', '49']}; {'id': '44', 'type': 'subscript', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'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': 'pathsep'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '57', 'type': 'for_statement', 'children': ['58', '59', '60']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'for_statement', 'children': ['62', '63', '75']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '72']}; {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'if_statement', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'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': 'os'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'normpath'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '88', 'type': 'raise_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '94'], 'value': '%'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"File not found: %s"'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'filename'}
|
Find file in current dir or system path
|
def _read_from_buffer(self, size=-1):
size = size if size >= 0 else len(self._buffer)
part = self._buffer.read(size)
self._current_pos += len(part)
return part
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_from_buffer'}; {'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': 'size'}; {'id': '7', 'type': 'unary_operator', 'children': ['8'], 'value': '-'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '9', 'type': 'block', 'children': ['10', '24', '35', '44']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '13', 'type': 'conditional_expression', 'children': ['14', '15', '18'], 'value': 'if'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '>='}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_buffer'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'part'}; {'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': '_buffer'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'augmented_assignment', 'children': ['37', '40'], 'value': '+='}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_current_pos'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'part'}
|
Remove at most size bytes from our buffer and return them.
|
async def send_api(container, targetname, name, params = {}):
handle = object()
apiEvent = ModuleAPICall(handle, targetname, name, params = params)
await container.wait_for_send(apiEvent)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_api'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'container'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'targetname'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '17', '29']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'apiEvent'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ModuleAPICall'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25', '26']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'targetname'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'await', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'container'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'wait_for_send'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'apiEvent'}
|
Send API and discard the result
|
def plot(self, overlay=True, **labels):
pylab = LazyImport.pylab()
colours = list('rgbymc')
colours_len = len(colours)
colours_pos = 0
plots = len(self.groups)
for name, series in self.groups.iteritems():
colour = colours[colours_pos % colours_len]
colours_pos += 1
if not overlay:
pylab.subplot(plots, 1, colours_pos)
kwargs = {}
if name in labels:
name = labels[name]
if name is not None:
kwargs['label'] = name
pylab.plot(series.dates, series.values, '%s-' % colour, **kwargs)
if name is not None:
pylab.legend()
pylab.show()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot'}; {'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': 'overlay'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '10', 'type': 'block', 'children': ['11', '19', '26', '33', '37', '46', '137']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pylab'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'LazyImport'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'pylab'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'colours'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'rgbymc'"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'colours_len'}; {'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': 'colours'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'colours_pos'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'plots'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '46', 'type': 'for_statement', 'children': ['47', '50', '57']}; {'id': '47', 'type': 'pattern_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'block', 'children': ['58', '66', '70', '83', '87', '98', '109', '126']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'colour'}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'colours'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '%'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'colours_pos'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'colours_len'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'augmented_assignment', 'children': ['68', '69'], 'value': '+='}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'colours_pos'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '73']}; {'id': '71', 'type': 'not_operator', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'overlay'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'pylab'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'subplot'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81', '82']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'plots'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'colours_pos'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '86', 'type': 'dictionary', 'children': []}; {'id': '87', 'type': 'if_statement', 'children': ['88', '91']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '90'], 'value': 'in'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '98', 'type': 'if_statement', 'children': ['99', '102']}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '101'], 'value': 'is not'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '101', 'type': 'None', 'children': []}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '108']}; {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '107', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'pylab'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '118', '121', '124']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'dates'}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'series'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '121', 'type': 'binary_operator', 'children': ['122', '123'], 'value': '%'}; {'id': '122', 'type': 'string', 'children': [], 'value': "'%s-'"}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'colour'}; {'id': '124', 'type': 'dictionary_splat', 'children': ['125']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '126', 'type': 'if_statement', 'children': ['127', '130']}; {'id': '127', 'type': 'comparison_operator', 'children': ['128', '129'], 'value': 'is not'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '129', 'type': 'None', 'children': []}; {'id': '130', 'type': 'block', 'children': ['131']}; {'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': 'pylab'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'legend'}; {'id': '136', 'type': 'argument_list', 'children': []}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'pylab'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'show'}; {'id': '142', 'type': 'argument_list', 'children': []}
|
Plot all time series in the group.
|
def explained_inertia_(self):
utils.validation.check_is_fitted(self, 'total_inertia_')
return [eig / self.total_inertia_ for eig in self.eigenvalues_]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'explained_inertia_'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'validation'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'check_is_fitted'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'total_inertia_'"}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'list_comprehension', 'children': ['18', '23']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '20'], 'value': '/'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'eig'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'total_inertia_'}; {'id': '23', 'type': 'for_in_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'eig'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'eigenvalues_'}
|
The percentage of explained inertia per principal component.
|
def _set_params(self):
if self.docs['in']['params']:
self.docs['out']['params'] = list(self.docs['in']['params'])
for e in self.element['params']:
if type(e) is tuple:
param = e[0]
else:
param = e
found = False
for i, p in enumerate(self.docs['out']['params']):
if param == p[0]:
found = True
if type(e) is tuple:
self.docs['out']['params'][i] = (p[0], p[1], p[2], e[1])
if not found:
if type(e) is tuple:
p = (param, '', None, e[1])
else:
p = (param, '', None, None)
self.docs['out']['params'].append(p)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_params'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '34']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'subscript', 'children': ['8', '13']}; {'id': '8', 'type': 'subscript', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'docs'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'in'"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'params'"}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '24']}; {'id': '17', 'type': 'subscript', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'docs'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'params'"}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'subscript', 'children': ['28', '33']}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'docs'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'in'"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'params'"}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '41']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'params'"}; {'id': '41', 'type': 'block', 'children': ['42', '62', '66', '124']}; {'id': '42', 'type': 'if_statement', 'children': ['43', '49', '56']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '48'], 'value': 'is'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'param'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '65', 'type': 'False', 'children': []}; {'id': '66', 'type': 'for_statement', 'children': ['67', '70', '80']}; {'id': '67', 'type': 'pattern_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'subscript', 'children': ['74', '79']}; {'id': '74', 'type': 'subscript', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'docs'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '79', 'type': 'string', 'children': [], 'value': "'params'"}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'if_statement', 'children': ['82', '87']}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '84'], 'value': '=='}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '87', 'type': 'block', 'children': ['88', '92']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '91', 'type': 'True', 'children': []}; {'id': '92', 'type': 'if_statement', 'children': ['93', '99']}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '98'], 'value': 'is'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '111']}; {'id': '102', 'type': 'subscript', 'children': ['103', '110']}; {'id': '103', 'type': 'subscript', 'children': ['104', '109']}; {'id': '104', 'type': 'subscript', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'docs'}; {'id': '108', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '109', 'type': 'string', 'children': [], 'value': "'params'"}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '111', 'type': 'tuple', 'children': ['112', '115', '118', '121']}; {'id': '112', 'type': 'subscript', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '114', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '115', 'type': 'subscript', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '117', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '120', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '121', 'type': 'subscript', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '123', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '124', 'type': 'if_statement', 'children': ['125', '127']}; {'id': '125', 'type': 'not_operator', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '127', 'type': 'block', 'children': ['128', '156']}; {'id': '128', 'type': 'if_statement', 'children': ['129', '135', '146']}; {'id': '129', 'type': 'comparison_operator', 'children': ['130', '134'], 'value': 'is'}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'assignment', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '139', 'type': 'tuple', 'children': ['140', '141', '142', '143']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '141', 'type': 'string', 'children': [], 'value': "''"}; {'id': '142', 'type': 'None', 'children': []}; {'id': '143', 'type': 'subscript', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '145', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '146', 'type': 'else_clause', 'children': ['147']}; {'id': '147', 'type': 'block', 'children': ['148']}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'assignment', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '151', 'type': 'tuple', 'children': ['152', '153', '154', '155']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '153', 'type': 'string', 'children': [], 'value': "''"}; {'id': '154', 'type': 'None', 'children': []}; {'id': '155', 'type': 'None', 'children': []}; {'id': '156', 'type': 'expression_statement', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '167']}; {'id': '158', 'type': 'attribute', 'children': ['159', '166']}; {'id': '159', 'type': 'subscript', 'children': ['160', '165']}; {'id': '160', 'type': 'subscript', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'docs'}; {'id': '164', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '165', 'type': 'string', 'children': [], 'value': "'params'"}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '167', 'type': 'argument_list', 'children': ['168']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'p'}
|
Sets the parameters with types, descriptions and default value if any
|
def SetOperator(self, operator):
self.operator = operator
attribute_type = self.attribute_obj.GetRDFValueType()
operators = attribute_type.operators
self.number_of_args, self.operator_method = operators.get(
operator, (0, None))
if self.operator_method is None:
raise lexer.ParseError("Operator %s not defined on attribute '%s'" %
(operator, self.attribute))
self.operator_method = getattr(attribute_type, self.operator_method)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'SetOperator'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '23', '29', '47', '67']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'attribute_type'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'attribute_obj'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'GetRDFValueType'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'operators'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'attribute_type'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'operators'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '38']}; {'id': '31', 'type': 'pattern_list', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'number_of_args'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'operator_method'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'operators'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '44', 'type': 'tuple', 'children': ['45', '46']}; {'id': '45', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '46', 'type': 'None', 'children': []}; {'id': '47', 'type': 'if_statement', 'children': ['48', '53']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '52'], 'value': 'is'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'operator_method'}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'raise_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'lexer'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ParseError'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '%'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"Operator %s not defined on attribute \'%s\'"'}; {'id': '62', 'type': 'tuple', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'operator_method'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'attribute_type'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'operator_method'}
|
Sets the operator for this expression.
|
def _validate_master(new_class):
if not new_class.master or not isinstance(new_class.master, ForwardManyToOneDescriptor):
raise ImproperlyConfigured("{0}.master should be a ForeignKey to the shared table.".format(new_class.__name__))
remote_field = new_class.master.field.remote_field
shared_model = remote_field.model
meta = shared_model._parler_meta
if meta is not None:
if meta._has_translations_model(new_class):
raise ImproperlyConfigured("The model '{0}' already has an associated translation table!".format(shared_model.__name__))
if meta._has_translations_field(remote_field.related_name):
raise ImproperlyConfigured("The model '{0}' already has an associated translation field named '{1}'!".format(shared_model.__name__, remote_field.related_name))
return shared_model
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_master'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'new_class'}; {'id': '5', 'type': 'block', 'children': ['6', '33', '43', '49', '55', '105']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '20']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '12'], 'value': 'or'}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'new_class'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'master'}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'new_class'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'master'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ForwardManyToOneDescriptor'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'raise_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ImproperlyConfigured'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"{0}.master should be a ForeignKey to the shared table."'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'new_class'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'remote_field'}; {'id': '36', 'type': 'attribute', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'new_class'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'master'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'remote_field'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'shared_model'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'remote_field'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'shared_model'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_parler_meta'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '59']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'is not'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '58', 'type': 'None', 'children': []}; {'id': '59', 'type': 'block', 'children': ['60', '80']}; {'id': '60', 'type': 'if_statement', 'children': ['61', '67']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_has_translations_model'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'new_class'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'raise_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'ImproperlyConfigured'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"The model \'{0}\' already has an associated translation table!"'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'shared_model'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '89']}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': '_has_translations_field'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'remote_field'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'related_name'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'raise_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ImproperlyConfigured'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': '"The model \'{0}\' already has an associated translation field named \'{1}\'!"'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'shared_model'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'remote_field'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'related_name'}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'shared_model'}
|
Check whether the 'master' field on a TranslatedFieldsModel is correctly configured.
|
def _install_from_path(path):
if not os.path.exists(path):
msg = 'File not found: {0}'.format(path)
raise SaltInvocationError(msg)
cmd = 'installer -pkg "{0}" -target /'.format(path)
return salt.utils.mac_utils.execute_return_success(cmd)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_install_from_path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6', '31', '40']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'block', 'children': ['17', '26']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'File not found: {0}'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'SaltInvocationError'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '\'installer -pkg "{0}" -target /\''}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '49']}; {'id': '42', 'type': 'attribute', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'mac_utils'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'execute_return_success'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'cmd'}
|
Internal function to install a package from the given path
|
def _format_json(self, ans, q):
params = {}
try: params['indent'] = int(q.get('indent')[0])
except: pass
return json.dumps(ans, **params)+'\n'
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ans'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '33']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '11', 'type': 'dictionary', 'children': []}; {'id': '12', 'type': 'try_statement', 'children': ['13', '30']}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'indent'"}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'subscript', 'children': ['23', '29']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'indent'"}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'except_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'pass_statement', 'children': []}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '43'], 'value': '+'}; {'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']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ans'}; {'id': '41', 'type': 'dictionary_splat', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'\\n'"}
|
Generate a json response string.
|
def file_matches(filename, patterns):
return any(fnmatch.fnmatch(filename, pat)
or fnmatch.fnmatch(os.path.basename(filename), pat)
for pat in patterns)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'file_matches'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'patterns'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '10', 'type': 'generator_expression', 'children': ['11', '33']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '19'], 'value': 'or'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pat'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '32']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'pat'}; {'id': '33', 'type': 'for_in_clause', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pat'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'patterns'}
|
Does this filename match any of the patterns?
|
def format_error(err_type, err_value, err_trace=None):
if err_trace is None:
err_parts = "".join(traceback.format_exception_only(err_type, err_value)).strip().split(": ", 1)
if len(err_parts) == 1:
err_name, err_msg = err_parts[0], ""
else:
err_name, err_msg = err_parts
err_name = err_name.split(".")[-1]
return err_name + ": " + err_msg
else:
return "".join(traceback.format_exception(err_type, err_value, err_trace)).strip()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_error'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'err_type'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'err_value'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'err_trace'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14', '84']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'err_trace'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '40', '66', '78']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'err_parts'}; {'id': '18', 'type': 'call', 'children': ['19', '37']}; {'id': '19', 'type': 'attribute', 'children': ['20', '36']}; {'id': '20', 'type': 'call', 'children': ['21', '35']}; {'id': '21', 'type': 'attribute', 'children': ['22', '34']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '""'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'format_exception_only'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'err_type'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'err_value'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '": "'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': 'if_statement', 'children': ['41', '47', '58']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '46'], 'value': '=='}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'err_parts'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'pattern_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'err_name'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'err_msg'}; {'id': '53', 'type': 'expression_list', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'err_parts'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'string', 'children': [], 'value': '""'}; {'id': '58', 'type': 'else_clause', 'children': ['59']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'pattern_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'err_name'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'err_msg'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'err_parts'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'err_name'}; {'id': '69', 'type': 'subscript', 'children': ['70', '76']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'err_name'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '76', 'type': 'unary_operator', 'children': ['77'], 'value': '-'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '83'], 'value': '+'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '82'], 'value': '+'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'err_name'}; {'id': '82', 'type': 'string', 'children': [], 'value': '": "'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'err_msg'}; {'id': '84', 'type': 'else_clause', 'children': ['85']}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '103']}; {'id': '88', 'type': 'attribute', 'children': ['89', '102']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'string', 'children': [], 'value': '""'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'format_exception'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100', '101']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'err_type'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'err_value'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'err_trace'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '103', 'type': 'argument_list', 'children': []}
|
Properly formats the specified error.
|
def actualize (self):
if self.actualized_:
return
self.actualized_ = True
ps = self.properties ()
properties = self.adjust_properties (ps)
actual_targets = []
for i in self.targets ():
actual_targets.append (i.actualize ())
self.actualize_sources (self.sources (), properties)
self.engine_.add_dependency (actual_targets, self.actual_sources_ + self.dependency_only_sources_)
import toolset
toolset.set_target_variables (self.manager_, self.action_name_, actual_targets, properties)
engine = self.manager_.engine ()
bjam.call("set-target-variable", actual_targets, ".action", repr(self))
self.manager_.engine ().set_update_action (self.action_name_, actual_targets, self.actual_sources_,
properties)
self.manager_.engine ().set_update_action ('common.Clean', 'clean-all',
actual_targets)
return actual_targets
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'actualize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '26', '35', '39', '58', '70', '86', '89', '103', '113', '126', '146', '161']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'actualized_'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': []}; {'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': 'actualized_'}; {'id': '17', 'type': 'True', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ps'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'adjust_properties'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ps'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'actual_targets'}; {'id': '38', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '46']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'i'}; {'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': 'targets'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'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': 'actual_targets'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'actualize'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'actualize_sources'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '69']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'engine_'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'add_dependency'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'actual_targets'}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '83'], 'value': '+'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'actual_sources_'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'dependency_only_sources_'}; {'id': '86', 'type': 'import_statement', 'children': ['87']}; {'id': '87', 'type': 'dotted_name', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'toolset'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'toolset'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'set_target_variables'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '98', '101', '102']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'manager_'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'action_name_'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'actual_targets'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '106', 'type': 'call', 'children': ['107', '112']}; {'id': '107', 'type': 'attribute', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'manager_'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '112', 'type': 'argument_list', 'children': []}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'bjam'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'call'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120', '121', '122']}; {'id': '119', 'type': 'string', 'children': [], 'value': '"set-target-variable"'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'actual_targets'}; {'id': '121', 'type': 'string', 'children': [], 'value': '".action"'}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '137']}; {'id': '128', 'type': 'attribute', 'children': ['129', '136']}; {'id': '129', 'type': 'call', 'children': ['130', '135']}; {'id': '130', 'type': 'attribute', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'manager_'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '135', 'type': 'argument_list', 'children': []}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'set_update_action'}; {'id': '137', 'type': 'argument_list', 'children': ['138', '141', '142', '145']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'action_name_'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'actual_targets'}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'actual_sources_'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '157']}; {'id': '148', 'type': 'attribute', 'children': ['149', '156']}; {'id': '149', 'type': 'call', 'children': ['150', '155']}; {'id': '150', 'type': 'attribute', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'manager_'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '155', 'type': 'argument_list', 'children': []}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'set_update_action'}; {'id': '157', 'type': 'argument_list', 'children': ['158', '159', '160']}; {'id': '158', 'type': 'string', 'children': [], 'value': "'common.Clean'"}; {'id': '159', 'type': 'string', 'children': [], 'value': "'clean-all'"}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'actual_targets'}; {'id': '161', 'type': 'return_statement', 'children': ['162']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'actual_targets'}
|
Generates actual build instructions.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.