code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def generate_rsa_key_pair(): key = rsa.generate_private_key( backend=default_backend(), public_exponent=65537, key_size=2048) public_key = key.public_key().public_bytes( serialization.Encoding.OpenSSH, serialization.PublicFormat.OpenSSH).decode("utf-8") pem = key.private_bytes( encoding=serialization.Encoding.PEM, format=serialization.PrivateFormat.TraditionalOpenSSL, encryption_algorithm=serialization.NoEncryption()).decode("utf-8") return public_key, pem
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_rsa_key_pair'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '24', '51', '85']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'rsa'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'generate_private_key'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '18', '21']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'default_backend'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'public_exponent'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '65537'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key_size'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '2048'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'public_key'}; {'id': '27', 'type': 'call', 'children': ['28', '49']}; {'id': '28', 'type': 'attribute', 'children': ['29', '48']}; {'id': '29', 'type': 'call', 'children': ['30', '37']}; {'id': '30', 'type': 'attribute', 'children': ['31', '36']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'public_key'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'public_bytes'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'serialization'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Encoding'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'OpenSSH'}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'serialization'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'PublicFormat'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'OpenSSH'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'pem'}; {'id': '54', 'type': 'call', 'children': ['55', '83']}; {'id': '55', 'type': 'attribute', 'children': ['56', '82']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'private_bytes'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '68', '75']}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'serialization'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Encoding'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'PEM'}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'serialization'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'PrivateFormat'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'TraditionalOpenSSL'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'encryption_algorithm'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'serialization'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'NoEncryption'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'expression_list', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'public_key'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'pem'}
Create public and private ssh-keys.
def generate_events_list(generator): if not localized_events: generator.context['events_list'] = sorted(events, reverse = True, key=lambda ev: (ev.dtstart, ev.dtend)) else: generator.context['events_list'] = {k: sorted(v, reverse = True, key=lambda ev: (ev.dtstart, ev.dtend)) for k, v in localized_events.items()}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_events_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'generator'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '9', '36']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'localized_events'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '17']}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'generator'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'events_list'"}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '24']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'events'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '23', 'type': 'True', 'children': []}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '26', 'type': 'lambda', 'children': ['27', '29']}; {'id': '27', 'type': 'lambda_parameters', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ev'}; {'id': '29', 'type': 'tuple', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ev'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dtstart'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ev'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'dtend'}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '45']}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'generator'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'events_list'"}; {'id': '45', 'type': 'dictionary_comprehension', 'children': ['46', '67']}; {'id': '46', 'type': 'pair', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52', '55']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '54', 'type': 'True', 'children': []}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '57', 'type': 'lambda', 'children': ['58', '60']}; {'id': '58', 'type': 'lambda_parameters', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ev'}; {'id': '60', 'type': 'tuple', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ev'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'dtstart'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ev'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'dtend'}; {'id': '67', 'type': 'for_in_clause', 'children': ['68', '71']}; {'id': '68', 'type': 'pattern_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'localized_events'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '75', 'type': 'argument_list', 'children': []}
Populate the event_list variable to be used in jinja templates
def mavlink_packet(self, m): if m.get_type() == 'GLOBAL_POSITION_INT': if abs(m.lat) < 1000 and abs(m.lon) < 1000: return self.vehicle_pos = VehiclePos(m)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mavlink_packet'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '14'], 'value': '=='}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_type'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'string', 'children': [], 'value': "'GLOBAL_POSITION_INT'"}; {'id': '15', 'type': 'block', 'children': ['16', '36']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '34']}; {'id': '17', 'type': 'boolean_operator', 'children': ['18', '26'], 'value': 'and'}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '25'], 'value': '<'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'lat'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '33'], 'value': '<'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'vehicle_pos'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'VehiclePos'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'm'}
get time from mavlink ATTITUDE
def read_dataset_metadata(self): if self.dataset_meta: return shell_call(['gsutil', 'cp', 'gs://' + self.storage_client.bucket_name + '/' + 'dataset/' + self.dataset_name + '_dataset.csv', LOCAL_DATASET_METADATA_FILE]) with open(LOCAL_DATASET_METADATA_FILE, 'r') as f: self.dataset_meta = eval_lib.DatasetMetadata(f)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_dataset_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '37']}; {'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': 'dataset_meta'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'shell_call'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'list', 'children': ['17', '18', '19', '36'], 'value': "['gsutil', 'cp',\n 'gs://' + self.storage_client.bucket_name + '/'\n + 'dataset/' + self.dataset_name + '_dataset.csv',\n LOCAL_DATASET_METADATA_FILE]"}; {'id': '17', 'type': 'string', 'children': [], 'value': "'gsutil'"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'cp'"}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '35'], 'value': '+'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '32'], 'value': '+'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '31'], 'value': '+'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '30'], 'value': '+'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '+'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'gs://'"}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'storage_client'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'bucket_name'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '31', 'type': 'string', 'children': [], 'value': "'dataset/'"}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dataset_name'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'_dataset.csv'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'LOCAL_DATASET_METADATA_FILE'}; {'id': '37', 'type': 'with_statement', 'children': ['38', '48']}; {'id': '38', 'type': 'with_clause', 'children': ['39']}; {'id': '39', 'type': 'with_item', 'children': ['40']}; {'id': '40', 'type': 'as_pattern', 'children': ['41', '46']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'LOCAL_DATASET_METADATA_FILE'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '46', 'type': 'as_pattern_target', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dataset_meta'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'eval_lib'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'DatasetMetadata'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'f'}
Read `dataset_meta` field from bucket
def dumps(obj, **kwargs) -> str: return json.dumps(obj, cls=BioCJSONEncoder, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dumps'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '20']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'BioCJSONEncoder'}; {'id': '20', 'type': 'dictionary_splat', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Serialize a BioC ``obj`` to a JSON formatted ``str``.
def findRoleID(self, name): for r in self: if r['name'].lower() == name.lower(): return r['id'] del r return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'findRoleID'}; {'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', '32']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '10']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'block', 'children': ['11', '30']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '25']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '20'], 'value': '=='}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '30', 'type': 'delete_statement', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'None', 'children': []}
searches the roles by name and returns the role's ID
def _setStyle(node, styleMap): u fixedStyle = ';'.join([prop + ':' + styleMap[prop] for prop in styleMap]) if fixedStyle != '': node.setAttribute('style', fixedStyle) elif node.getAttribute('style'): node.removeAttribute('style') return node
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_setStyle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'styleMap'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '28', '56']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fixedStyle'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "';'"}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'list_comprehension', 'children': ['18', '25']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '+'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '+'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '21', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'styleMap'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'styleMap'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32', '41']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '!='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'fixedStyle'}; {'id': '31', 'type': 'string', 'children': [], 'value': "''"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'setAttribute'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'style'"}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fixedStyle'}; {'id': '41', 'type': 'elif_clause', 'children': ['42', '48']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'getAttribute'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'style'"}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'removeAttribute'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'style'"}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'node'}
u"""Sets the style attribute of a node to the dictionary ``styleMap``.
def domain(self): remove_pac = self.cleanup.replace( "https://", "").replace("http://", "").replace("www.", "") try: return remove_pac.split('/')[0] except: return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'domain'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '30']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'remove_pac'}; {'id': '9', 'type': 'call', 'children': ['10', '27']}; {'id': '10', 'type': 'attribute', 'children': ['11', '26']}; {'id': '11', 'type': 'call', 'children': ['12', '23']}; {'id': '12', 'type': 'attribute', 'children': ['13', '22']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cleanup'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"https://"'}; {'id': '21', 'type': 'string', 'children': [], 'value': '""'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"http://"'}; {'id': '25', 'type': 'string', 'children': [], 'value': '""'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"www."'}; {'id': '29', 'type': 'string', 'children': [], 'value': '""'}; {'id': '30', 'type': 'try_statement', 'children': ['31', '41']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'subscript', 'children': ['34', '40']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'remove_pac'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '41', 'type': 'except_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'None', 'children': []}
Return domain from the url
def addNode(self, node): self.mybldgbuids[node.buid] = node self.allbldgbuids[node.buid] = (node, self.doneevent)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addNode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '16']}; {'id': '9', 'type': 'subscript', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'mybldgbuids'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'buid'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '26']}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'allbldgbuids'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'buid'}; {'id': '26', 'type': 'tuple', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'doneevent'}
Update the shared map with my in-construction node
def _construct_timeseries(self, timeseries, constraints={}): self.response_from(timeseries, constraints) if self.response == None: return None return {'data':self.response['data'], 'period':self.response['period'], 'start time':datetime.datetime.fromtimestamp(self.response['start_time']), 'end time':datetime.datetime.fromtimestamp(self.response['end_time'])}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_construct_timeseries'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'timeseries'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'constraints'}; {'id': '8', 'type': 'dictionary', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '18', '27']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'response_from'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'timeseries'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'constraints'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '24']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '23'], 'value': '=='}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'dictionary', 'children': ['29', '36', '43', '57']}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'data'"}; {'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': 'response'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '36', 'type': 'pair', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'period'"}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'period'"}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'start time'"}; {'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': 'datetime'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fromtimestamp'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'subscript', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'start_time'"}; {'id': '57', 'type': 'pair', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'end time'"}; {'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': 'datetime'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'fromtimestamp'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'subscript', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'end_time'"}
wraps response_from for timeseries calls, returns the resulting dict
def between(y, z): return _combinable(lambda x: (y <= x < z) or _equal_or_float_equal(x, y))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'between'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'z'}; {'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': '_combinable'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'lambda', 'children': ['12', '14']}; {'id': '12', 'type': 'lambda_parameters', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '20'], 'value': 'or'}; {'id': '15', 'type': '()', 'children': ['16']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18', '19'], 'value': '<='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_equal_or_float_equal'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'y'}
Greater than or equal to y and less than z.
def _zeep_to_dict(cls, obj): res = serialize_object(obj) res = cls._get_non_empty_dict(res) return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_zeep_to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '23']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'serialize_object'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_get_non_empty_dict'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'res'}
Convert a zeep object to a dictionary.
def _check_apt_get(): check = False if 'TESTING' not in os.environ: result = exec_command(['dpkg', '-l', 'apio']) if result and result.get('returncode') == 0: match = re.findall('rc\s+apio', result.get('out')) + \ re.findall('ii\s+apio', result.get('out')) check = len(match) > 0 return check
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_apt_get'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '76']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'not in'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'TESTING'"}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '15', 'type': 'block', 'children': ['16', '26']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'exec_command'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'list', 'children': ['23', '24', '25'], 'value': "['dpkg', '-l', 'apio']"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'dpkg'"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'-l'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "'apio'"}; {'id': '26', 'type': 'if_statement', 'children': ['27', '37']}; {'id': '27', 'type': 'boolean_operator', 'children': ['28', '29'], 'value': 'and'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '36'], 'value': '=='}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'returncode'"}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '37', 'type': 'block', 'children': ['38', '67']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '54', '55'], 'value': '+'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'rc\\s+apio'"}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '54', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'ii\\s+apio'"}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'out'"}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'check'}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '75'], 'value': '>'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'check'}
Check if apio can be installed through apt-get
def run_ajax_spider(self, target_url): self.logger.debug('AJAX Spidering target {0}...'.format(target_url)) self.zap.ajaxSpider.scan(target_url) while self.zap.ajaxSpider.status == 'running': self.logger.debug('AJAX Spider: {0}'.format(self.zap.ajaxSpider.status)) time.sleep(self._status_check_sleep) self.logger.debug('AJAX Spider completed')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_ajax_spider'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target_url'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '32', '72']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'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': "'AJAX Spidering target {0}...'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'target_url'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '30']}; {'id': '23', 'type': 'attribute', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'zap'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ajaxSpider'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'scan'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'target_url'}; {'id': '32', 'type': 'while_statement', 'children': ['33', '42']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '41'], 'value': '=='}; {'id': '34', 'type': 'attribute', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'zap'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ajaxSpider'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'running'"}; {'id': '42', 'type': 'block', 'children': ['43', '63']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'AJAX Spider: {0}'"}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'attribute', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'zap'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'ajaxSpider'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_status_check_sleep'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '79']}; {'id': '74', 'type': 'attribute', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'string', 'children': [], 'value': "'AJAX Spider completed'"}
Run AJAX Spider against a URL.
def migrate(dest_datastore, source_datastore): for uid in source_datastore.list(): try: paste = source_datastore._retrieve(uid) except Exception as exc: print( "{exc.__class__.__name__} occurred retrieving {uid}: {exc}" .format(exc=exc, uid=uid), file=sys.stderr) continue data = paste.pop('data', None) try: dest_datastore._store(uid, paste, data) except Exception as exc: print( "{exc.__class__.__name__} occurred storing {uid}: {exc}" .format(exc=exc, uid=uid), file=sys.stderr) continue
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'migrate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dest_datastore'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'source_datastore'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '14']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'source_datastore'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '53', '63']}; {'id': '15', 'type': 'try_statement', 'children': ['16', '26']}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'paste'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'source_datastore'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_retrieve'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '26', 'type': 'except_clause', 'children': ['27', '31']}; {'id': '27', 'type': 'as_pattern', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '29', 'type': 'as_pattern_target', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '31', 'type': 'block', 'children': ['32', '52']}; {'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', '47']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"{exc.__class__.__name__} occurred retrieving {uid}: {exc}"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44']}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '52', 'type': 'continue_statement', 'children': []}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'paste'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '62', 'type': 'None', 'children': []}; {'id': '63', 'type': 'try_statement', 'children': ['64', '74']}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'dest_datastore'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_store'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72', '73']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'paste'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '74', 'type': 'except_clause', 'children': ['75', '79']}; {'id': '75', 'type': 'as_pattern', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '77', 'type': 'as_pattern_target', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '79', 'type': 'block', 'children': ['80', '100']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '95']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': '"{exc.__class__.__name__} occurred storing {uid}: {exc}"'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '92']}; {'id': '89', 'type': 'keyword_argument', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '92', 'type': 'keyword_argument', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '95', 'type': 'keyword_argument', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '100', 'type': 'continue_statement', 'children': []}
Copy all records from source_datastore to dest_datastore
def show_port(self, port, **_params): return self.get(self.port_path % (port), params=_params)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_port'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': '_params'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '21']}; {'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': 'port_path'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_params'}
Fetches information of a certain port.
def query(transport, query): with CommandLineClient(transport) as client: echo_event(client.query(query))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'as_pattern', 'children': ['11', '15']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'CommandLineClient'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'transport'}; {'id': '15', 'type': 'as_pattern_target', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'echo_event'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'query'}
Query the Riemann server
def add(self, dist): new_path = ( dist.location not in self.paths and ( dist.location not in self.sitedirs or dist.location == os.getcwd() ) ) if new_path: self.paths.append(dist.location) self.dirty = True Environment.add(self, dist)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '6', 'type': 'block', 'children': ['7', '37', '57']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'new_path'}; {'id': '10', 'type': '()', 'children': ['11']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '19'], 'value': 'and'}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '16'], 'value': 'not in'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '28'], 'value': 'or'}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '25'], 'value': 'not in'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sitedirs'}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': '=='}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'if_statement', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'new_path'}; {'id': '39', 'type': 'block', 'children': ['40', '51']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'dist'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'dirty'}; {'id': '56', 'type': 'True', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'Environment'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'dist'}
Add `dist` to the distribution map
def height_water_critical(FlowRate, Width): ut.check_range([FlowRate, ">0", "Flow rate"], [Width, ">0", "Width"]) return (FlowRate / (Width * np.sqrt(gravity.magnitude))) ** (2/3)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'height_water_critical'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'FlowRate'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'Width'}; {'id': '6', 'type': 'block', 'children': ['7', '21']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ut'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'check_range'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '17']}; {'id': '13', 'type': 'list', 'children': ['14', '15', '16'], 'value': '[FlowRate, ">0", "Flow rate"]'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'FlowRate'}; {'id': '15', 'type': 'string', 'children': [], 'value': '">0"'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"Flow rate"'}; {'id': '17', 'type': 'list', 'children': ['18', '19', '20'], 'value': '[Width, ">0", "Width"]'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Width'}; {'id': '19', 'type': 'string', 'children': [], 'value': '">0"'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Width"'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '37'], 'value': '**'}; {'id': '23', 'type': '()', 'children': ['24']}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '/'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'FlowRate'}; {'id': '26', 'type': '()', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '*'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Width'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'gravity'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'magnitude'}; {'id': '37', 'type': '()', 'children': ['38']}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '/'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '3'}
Return the critical local water depth.
def getVolInfo(*paths): path = os.path.join(*paths) path = os.path.expanduser(path) st = os.statvfs(path) free = st.f_bavail * st.f_frsize total = st.f_blocks * st.f_frsize return { 'free': free, 'used': total - free, 'total': total, }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getVolInfo'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '30', '39', '49', '59']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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']}; {'id': '17', 'type': 'list_splat', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'st'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'statvfs'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'free'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '46'], 'value': '*'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'st'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'f_bavail'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'st'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'f_frsize'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '56'], 'value': '*'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'st'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'f_blocks'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'st'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'f_frsize'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'dictionary', 'children': ['61', '64', '69']}; {'id': '61', 'type': 'pair', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'free'"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'free'}; {'id': '64', 'type': 'pair', 'children': ['65', '66']}; {'id': '65', 'type': 'string', 'children': [], 'value': "'used'"}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '68'], 'value': '-'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'free'}; {'id': '69', 'type': 'pair', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'total'"}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'total'}
Retrieve volume usage info for the given path.
def _get_users(self, user_base): results = self._search( getattr(self, '_%s_user_base' % user_base), '(objectClass=*)', ['*'], scope=ldap.SCOPE_ONELEVEL ) for dn, attrs in results: uid = attrs.get('uid')[0].decode('utf-8', 'ignore') getattr(self, '_%s_users' % user_base)[uid] = FreeIPAUser(dn, attrs) log.debug('%s users: %s' % (user_base.capitalize(), len(getattr(self, '_%s_users' % user_base))))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_users'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'user_base'}; {'id': '6', 'type': 'block', 'children': ['7', '30', '69']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_search'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '22', '23', '25']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '%'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'_%s_user_base'"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'user_base'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'(objectClass=*)'"}; {'id': '23', 'type': 'list', 'children': ['24'], 'value': "['*']"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ldap'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'SCOPE_ONELEVEL'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '34', '35']}; {'id': '31', 'type': 'pattern_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dn'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '35', 'type': 'block', 'children': ['36', '53']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '39', 'type': 'call', 'children': ['40', '50']}; {'id': '40', 'type': 'attribute', 'children': ['41', '49']}; {'id': '41', 'type': 'subscript', 'children': ['42', '48']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'uid'"}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '52', 'type': 'string', 'children': [], 'value': "'ignore'"}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '64']}; {'id': '55', 'type': 'subscript', 'children': ['56', '63']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '%'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'_%s_users'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'user_base'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'FreeIPAUser'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'dn'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '%'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'%s users: %s'"}; {'id': '77', 'type': 'tuple', 'children': ['78', '83']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'user_base'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'capitalize'}; {'id': '82', 'type': 'argument_list', 'children': []}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '92'], 'value': '%'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'_%s_users'"}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'user_base'}
Get users from LDAP
def map_helper(data): as_list = [] length = 2 for field, value in data.items(): as_list.append(Container(field=bytes(field, ENCODING), value=bytes(value, ENCODING))) length += len(field) + len(value) + 4 return (Container( num=len(as_list), map=as_list ), length)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_helper'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '61']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'as_list'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '18', '23']}; {'id': '15', 'type': 'pattern_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24', '47']}; {'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': 'as_list'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'Container'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '40']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ENCODING'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ENCODING'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'augmented_assignment', 'children': ['49', '50'], 'value': '+='}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '60'], 'value': '+'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '56'], 'value': '+'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'field'}; {'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': 'value'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'tuple', 'children': ['63', '75']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'Container'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '72']}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'as_list'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'as_list'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'length'}
Build a map message.
def flush(self): if self._num_outstanding_events == 0 or self._recordio_writer is None: return self._recordio_writer.flush() if self._logger is not None: self._logger.info('wrote %d %s to disk', self._num_outstanding_events, 'event' if self._num_outstanding_events == 1 else 'events') self._num_outstanding_events = 0
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flush'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '28', '55']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '18']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '13'], 'value': 'or'}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': '=='}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_num_outstanding_events'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': 'is'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_recordio_writer'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_recordio_writer'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'if_statement', 'children': ['29', '34']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '33'], 'value': 'is not'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44', '47']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'wrote %d %s to disk'"}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_num_outstanding_events'}; {'id': '47', 'type': 'conditional_expression', 'children': ['48', '49', '54'], 'value': 'if'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'event'"}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '53'], 'value': '=='}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_num_outstanding_events'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'events'"}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_num_outstanding_events'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '0'}
Flushes the event file to disk.
def _byte_buffer_md5(buffer_): md5 = hashlib.md5(buffer_) byte_digest = md5.digest() return base64.b64encode(byte_digest).decode()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_byte_buffer_md5'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'buffer_'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'buffer_'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'byte_digest'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'digest'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '33']}; {'id': '25', 'type': 'attribute', 'children': ['26', '32']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'base64'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'b64encode'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'byte_digest'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '33', 'type': 'argument_list', 'children': []}
Computes the md5 digest of a byte buffer in base64 encoding.
def load(fp, cls=BinaryQuadraticModel, vartype=None): pattern = re.compile(_LINE_REGEX) vartype_pattern = re.compile(_VARTYPE_HEADER_REGEX) triplets = [] for line in fp: triplets.extend(pattern.findall(line)) vt = vartype_pattern.findall(line) if vt: if vartype is None: vartype = vt[0] else: if isinstance(vartype, str): vartype = Vartype[vartype] else: vartype = Vartype(vartype) if Vartype[vt[0]] != vartype: raise ValueError("vartypes from headers and/or inputs do not match") if vartype is None: raise ValueError("vartype must be provided either as a header or as an argument") bqm = cls.empty(vartype) for u, v, bias in triplets: if u == v: bqm.add_variable(int(u), float(bias)) else: bqm.add_interaction(int(u), int(v), float(bias)) return bqm
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'BinaryQuadraticModel'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '21', '30', '34', '111', '121', '130', '176']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_LINE_REGEX'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'vartype_pattern'}; {'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': 'compile'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_VARTYPE_HEADER_REGEX'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'triplets'}; {'id': '33', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'fp'}; {'id': '37', 'type': 'block', 'children': ['38', '50', '59']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'triplets'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'vt'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'vartype_pattern'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '59', 'type': 'if_statement', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'vt'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'if_statement', 'children': ['63', '66', '73']}; {'id': '63', 'type': 'comparison_operator', 'children': ['64', '65'], 'value': 'is'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'vt'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'else_clause', 'children': ['74']}; {'id': '74', 'type': 'block', 'children': ['75', '97']}; {'id': '75', 'type': 'if_statement', 'children': ['76', '81', '88']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'Vartype'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '88', 'type': 'else_clause', 'children': ['89']}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'Vartype'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '97', 'type': 'if_statement', 'children': ['98', '105']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '104'], 'value': '!='}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'Vartype'}; {'id': '101', 'type': 'subscript', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'vt'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'raise_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'string', 'children': [], 'value': '"vartypes from headers and/or inputs do not match"'}; {'id': '111', 'type': 'if_statement', 'children': ['112', '115']}; {'id': '112', 'type': 'comparison_operator', 'children': ['113', '114'], 'value': 'is'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '114', 'type': 'None', 'children': []}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'raise_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'string', 'children': [], 'value': '"vartype must be provided either as a header or as an argument"'}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'bqm'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'vartype'}; {'id': '130', 'type': 'for_statement', 'children': ['131', '135', '136']}; {'id': '131', 'type': 'pattern_list', 'children': ['132', '133', '134']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'bias'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'triplets'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'if_statement', 'children': ['138', '141', '156']}; {'id': '138', 'type': 'comparison_operator', 'children': ['139', '140'], 'value': '=='}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '141', 'type': 'block', 'children': ['142']}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}; {'id': '143', 'type': 'call', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'bqm'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'add_variable'}; {'id': '147', 'type': 'argument_list', 'children': ['148', '152']}; {'id': '148', 'type': 'call', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'bias'}; {'id': '156', 'type': 'else_clause', 'children': ['157']}; {'id': '157', 'type': 'block', 'children': ['158']}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}; {'id': '159', 'type': 'call', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'bqm'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'add_interaction'}; {'id': '163', 'type': 'argument_list', 'children': ['164', '168', '172']}; {'id': '164', 'type': 'call', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '168', 'type': 'call', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '172', 'type': 'call', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '174', 'type': 'argument_list', 'children': ['175']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'bias'}; {'id': '176', 'type': 'return_statement', 'children': ['177']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'bqm'}
Load a COOrdinate formatted binary quadratic model from a file.
def close(self): if (self.__ser is not None): self.__ser.close() if (self.__tcpClientSocket is not None): self.__stoplistening = True self.__tcpClientSocket.shutdown(socket.SHUT_RDWR) self.__tcpClientSocket.close() self.__connected = False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '22', '55']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': '()', 'children': ['8']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is not'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '__ser'}; {'id': '12', 'type': 'None', 'children': []}; {'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': '__ser'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '29']}; {'id': '23', 'type': '()', 'children': ['24']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '28'], 'value': 'is not'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '__tcpClientSocket'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30', '36', '47']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '__stoplistening'}; {'id': '35', 'type': 'True', 'children': []}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'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': '__tcpClientSocket'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'shutdown'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'SHUT_RDWR'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '__tcpClientSocket'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '__connected'}; {'id': '60', 'type': 'False', 'children': []}
Closes Serial port, or TCP-Socket connection
def _to_query_json(self): return { 'quote': self._quote, 'fieldDelimiter': self._delimiter, 'encoding': self._encoding.upper(), 'skipLeadingRows': self._skip_leading_rows, 'allowQuotedNewlines': self._allow_quoted_newlines, 'allowJaggedRows': self._allow_jagged_rows }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_to_query_json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'dictionary', 'children': ['8', '13', '18', '27', '32', '37']}; {'id': '8', 'type': 'pair', 'children': ['9', '10']}; {'id': '9', 'type': 'string', 'children': [], 'value': "'quote'"}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_quote'}; {'id': '13', 'type': 'pair', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'fieldDelimiter'"}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_delimiter'}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'encoding'"}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_encoding'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'skipLeadingRows'"}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_skip_leading_rows'}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'allowQuotedNewlines'"}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_allow_quoted_newlines'}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'allowJaggedRows'"}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_allow_jagged_rows'}
Return the options as a dictionary to be used as JSON in a query job.
def execPath(self): vers = self.version.label if self.version else None return self.installedApp.exec_path(vers)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execPath'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'vers'}; {'id': '9', 'type': 'conditional_expression', 'children': ['10', '15', '18'], 'value': 'if'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'installedApp'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'exec_path'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'vers'}
the executable application's path
def resize(self, width, height): 'Set the canvas size in pixels' self.canvas.SetInitialSize(wx.Size(width, height)) self.window.GetSizer().Fit(self.window)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '7', 'type': 'block', 'children': ['8', '10', '25']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'string', 'children': [], 'value': "'Set the canvas size in pixels'"}; {'id': '10', 'type': 'expression_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': 'canvas'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'SetInitialSize'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'wx'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Size'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '36']}; {'id': '27', 'type': 'attribute', 'children': ['28', '35']}; {'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': 'window'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'GetSizer'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Fit'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'window'}
Set the canvas size in pixels
def data_to_sys_base(self): if not self.n or self._flags['sysbase'] is True: return self.copy_data_ext(model='Synchronous', field='Sn', dest='Sn', idx=self.gen) super(GovernorBase, self).data_to_sys_base() self._store['R'] = self.R self.R = self.system.mva * div(self.R, self.Sn)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_to_sys_base'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21', '41', '51', '61']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '19']}; {'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': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '18'], 'value': 'is'}; {'id': '13', 'type': 'subscript', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_flags'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'sysbase'"}; {'id': '18', 'type': 'True', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'copy_data_ext'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30', '33', '36']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'Synchronous'"}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'Sn'"}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'Sn'"}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'gen'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '50']}; {'id': '43', 'type': 'attribute', 'children': ['44', '49']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'GovernorBase'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'data_to_sys_base'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '58']}; {'id': '53', 'type': 'subscript', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_store'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'R'"}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '72'], 'value': '*'}; {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'mva'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'div'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'Sn'}
Custom system base conversion function
def tutor_courses(self): tutoring = self.user.courses_tutoring.all().filter(active__exact=True) owning = self.user.courses.all().filter(active__exact=True) result = (tutoring | owning).distinct() return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tutor_courses'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '25', '44', '55']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tutoring'}; {'id': '9', 'type': 'call', 'children': ['10', '21']}; {'id': '10', 'type': 'attribute', 'children': ['11', '20']}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'courses_tutoring'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'active__exact'}; {'id': '24', 'type': 'True', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'owning'}; {'id': '28', 'type': 'call', 'children': ['29', '40']}; {'id': '29', 'type': 'attribute', 'children': ['30', '39']}; {'id': '30', 'type': 'call', 'children': ['31', '38']}; {'id': '31', 'type': 'attribute', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'courses'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'active__exact'}; {'id': '43', 'type': 'True', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '47', 'type': 'call', 'children': ['48', '54']}; {'id': '48', 'type': 'attribute', 'children': ['49', '53']}; {'id': '49', 'type': '()', 'children': ['50']}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '|'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'tutoring'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'owning'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'distinct'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'result'}
Returns the list of courses this user is tutor or owner for.
def _IsUnparsedFlagAccessAllowed(self, name): if _UNPARSED_FLAG_ACCESS_ENV_NAME in os.environ: allow_unparsed_flag_access = ( os.getenv(_UNPARSED_FLAG_ACCESS_ENV_NAME) == '1') elif self.__dict__['__reset_called']: allow_unparsed_flag_access = False elif _helpers.IsRunningTest(): name_bytes = name.encode('utf8') if not isinstance(name, bytes) else name flag_percentile = ( struct.unpack('<I', hashlib.md5(name_bytes).digest()[:4])[0] % 100) allow_unparsed_flag_access = ( _UNPARSED_ACCESS_DISABLED_PERCENT <= flag_percentile) else: allow_unparsed_flag_access = True return allow_unparsed_flag_access
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_IsUnparsedFlagAccessAllowed'}; {'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', '102']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '26', '37', '96']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_UNPARSED_FLAG_ACCESS_ENV_NAME'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'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': 'allow_unparsed_flag_access'}; {'id': '17', 'type': '()', 'children': ['18']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '25'], 'value': '=='}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'getenv'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_UNPARSED_FLAG_ACCESS_ENV_NAME'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'1'"}; {'id': '26', 'type': 'elif_clause', 'children': ['27', '32']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'__reset_called'"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'allow_unparsed_flag_access'}; {'id': '36', 'type': 'False', 'children': []}; {'id': '37', 'type': 'elif_clause', 'children': ['38', '43']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_helpers'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'IsRunningTest'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'block', 'children': ['44', '61', '89']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'name_bytes'}; {'id': '47', 'type': 'conditional_expression', 'children': ['48', '54', '60'], 'value': 'if'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'utf8'"}; {'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': 'name'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'flag_percentile'}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '88'], 'value': '%'}; {'id': '66', 'type': 'subscript', 'children': ['67', '87']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'unpack'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'<I'"}; {'id': '73', 'type': 'subscript', 'children': ['74', '84']}; {'id': '74', 'type': 'call', 'children': ['75', '83']}; {'id': '75', 'type': 'attribute', 'children': ['76', '82']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'name_bytes'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'digest'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'slice', 'children': ['85', '86']}; {'id': '85', 'type': 'colon', 'children': []}; {'id': '86', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'allow_unparsed_flag_access'}; {'id': '92', 'type': '()', 'children': ['93']}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': '<='}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_UNPARSED_ACCESS_DISABLED_PERCENT'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'flag_percentile'}; {'id': '96', 'type': 'else_clause', 'children': ['97']}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'allow_unparsed_flag_access'}; {'id': '101', 'type': 'True', 'children': []}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'allow_unparsed_flag_access'}
Determine whether to allow unparsed flag access or not.
def all(*validators): def validate_all(fields): for validator in validators: errors = validator(fields) if errors: return errors validate_all.__doc__ = " and ".join(validator.__doc__ for validator in validators) return validate_all
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'validators'}; {'id': '6', 'type': 'block', 'children': ['7', '28', '44']}; {'id': '7', 'type': 'function_definition', 'children': ['8', '9', '11']}; {'id': '8', 'type': 'function_name', 'children': [], 'value': 'validate_all'}; {'id': '9', 'type': 'parameters', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'for_statement', 'children': ['13', '14', '15']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'validator'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'validators'}; {'id': '15', 'type': 'block', 'children': ['16', '23']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'validator'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'validate_all'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '" and "'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '37', 'type': 'generator_expression', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'validator'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'validator'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'validators'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'validate_all'}
Validation only succeeds if all passed in validators return no errors
def _submit(primitive, port_index, tuple_): args = (_get_opc(primitive), port_index, tuple_) _ec._submit(args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_submit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'primitive'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'port_index'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tuple_'}; {'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': 'args'}; {'id': '11', 'type': 'tuple', 'children': ['12', '16', '17']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_get_opc'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'primitive'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'port_index'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tuple_'}; {'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': '_ec'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_submit'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'args'}
Internal method to submit a tuple
def show_attrs(directory): "print out the tempo for each audio file in the given directory" for f in os.listdir(directory): if _is_audio(f): path = os.path.join(directory, f) _show_one(path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_attrs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '5', 'type': 'block', 'children': ['6', '8']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"print out the tempo for each audio file in the given directory"'}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '16']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'f'}; {'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': 'listdir'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '22']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_is_audio'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '22', 'type': 'block', 'children': ['23', '35']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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': 'os'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_show_one'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'path'}
print out the tempo for each audio file in the given directory
def author_line(soup): author_line = None authors_json_data = authors_json(soup) author_names = extract_author_line_names(authors_json_data) if len(author_names) > 0: author_line = format_author_line(author_names) return author_line
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'author_line'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '17', '24', '39']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'author_line'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'authors_json_data'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'authors_json'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'author_names'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'extract_author_line_names'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'authors_json_data'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '31']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '30'], 'value': '>'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'author_names'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'author_line'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'format_author_line'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'author_names'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'author_line'}
take preferred names from authors json and format them into an author line
def send(self, data): assert isinstance(data, text_type) self.stdout.write(data.replace('\n', '\r\n')) self.stdout.flush()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '28']}; {'id': '7', 'type': 'assert_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'text_type'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '27', 'type': 'string', 'children': [], 'value': "'\\r\\n'"}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'flush'}; {'id': '35', 'type': 'argument_list', 'children': []}
Send text to the client.
def foreignkey(element, exceptions): label = element.field.__dict__['label'] try: label = unicode(label) except NameError: pass if (not label) or (label in exceptions): return False else: return "_queryset" in element.field.__dict__
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'foreignkey'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '30']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '10', 'type': 'subscript', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '17', 'type': 'try_statement', 'children': ['18', '26']}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '26', 'type': 'except_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'NameError'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'pass_statement', 'children': []}; {'id': '30', 'type': 'if_statement', 'children': ['31', '39', '42']}; {'id': '31', 'type': 'boolean_operator', 'children': ['32', '35'], 'value': 'or'}; {'id': '32', 'type': '()', 'children': ['33']}; {'id': '33', 'type': 'not_operator', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '35', 'type': '()', 'children': ['36']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'in'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'False', 'children': []}; {'id': '42', 'type': 'else_clause', 'children': ['43']}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '47'], 'value': 'in'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"_queryset"'}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '__dict__'}
function to determine if each select field needs a create button or not
def getEditorBinary(self, cmdVersion=False): return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UE4Editor' + self._editorPathSuffix(cmdVersion))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getEditorBinary'}; {'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': 'cmdVersion'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', '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': 'os'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '22', '23', '24', '29']}; {'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': 'getEngineRoot'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'string', 'children': [], 'value': "'Engine'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'Binaries'"}; {'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': 'getPlatformIdentifier'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '+'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'UE4Editor'"}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_editorPathSuffix'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cmdVersion'}
Determines the location of the UE4Editor binary
def encode_basic_auth(username, password): return "Basic {}".format( b64encode( "{}:{}".format( username, password, ).encode("utf-8") ).decode("utf-8") )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode_basic_auth'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"Basic {}"'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '31']}; {'id': '14', 'type': 'attribute', 'children': ['15', '30']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'b64encode'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '28']}; {'id': '19', 'type': 'attribute', 'children': ['20', '27']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"{}:{}"'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"utf-8"'}
Encode basic auth credentials.
def SaveResourceUsage(self, client_id, status): self.hunt_obj.ProcessClientResourcesStats(client_id, status) self.UpdateProtoResources(status)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'SaveResourceUsage'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '7', 'type': 'block', 'children': ['8', '18']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'hunt_obj'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ProcessClientResourcesStats'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'status'}; {'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': 'UpdateProtoResources'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'status'}
Update the resource usage of the hunt.
def _persist_result(self): self._prepare_persistence_engine() return self._persistence_engine.store_async_result( self.id, self.result)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_persist_result'}; {'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': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_prepare_persistence_engine'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_persistence_engine'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'store_async_result'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'result'}
Store this Async's result in persistent storage.
def _remove_observation_from_means(self, xj, yj): self._mean_x_in_window = ((self.window_size * self._mean_x_in_window - xj) / (self.window_size - 1.0)) self._mean_y_in_window = ((self.window_size * self._mean_y_in_window - yj) / (self.window_size - 1.0))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_remove_observation_from_means'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'xj'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'yj'}; {'id': '7', 'type': 'block', 'children': ['8', '31']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_mean_x_in_window'}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '25'], 'value': '/'}; {'id': '15', 'type': '()', 'children': ['16']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '24'], 'value': '-'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '21'], 'value': '*'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'window_size'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_mean_x_in_window'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'xj'}; {'id': '25', 'type': '()', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '30'], 'value': '-'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'window_size'}; {'id': '30', 'type': 'float', 'children': [], 'value': '1.0'}; {'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': '_mean_y_in_window'}; {'id': '36', 'type': '()', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '48'], 'value': '/'}; {'id': '38', 'type': '()', 'children': ['39']}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '47'], 'value': '-'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '44'], 'value': '*'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'window_size'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_mean_y_in_window'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'yj'}; {'id': '48', 'type': '()', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '53'], 'value': '-'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'window_size'}; {'id': '53', 'type': 'float', 'children': [], 'value': '1.0'}
Update the means without recalculating for the deletion of one observation.
def create_dir_unless_exists(*args): path = os.path.join(*args) if not os.path.isdir(path): os.makedirs(path)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_dir_unless_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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']}; {'id': '17', 'type': 'list_splat', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '29']}; {'id': '20', 'type': 'not_operator', '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': 'isdir'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'path'}
Creates a directory unless it exists already.
def flo(string): callers_locals = {} frame = inspect.currentframe() try: outerframe = frame.f_back callers_locals = outerframe.f_locals finally: del frame return string.format(**callers_locals)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flo'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '18', '36']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'callers_locals'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'currentframe'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'try_statement', 'children': ['19', '32']}; {'id': '19', 'type': 'block', 'children': ['20', '26']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'outerframe'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'f_back'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'callers_locals'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'outerframe'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'f_locals'}; {'id': '32', 'type': 'finally_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'delete_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'dictionary_splat', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'callers_locals'}
Return the string given by param formatted with the callers locals.
def load_replacement_patterns(self): filename = self.dictionary + '.py' models = self.language + '_models_cltk' rel_path = os.path.join('~/cltk_data', self.language, 'model', models, 'semantics', filename) path = os.path.expanduser(rel_path) logger.info('Loading lemmata or synonyms. This may take a minute.') loader = importlib.machinery.SourceFileLoader(filename, path) module = types.ModuleType(loader.name) loader.exec_module(module) return module.DICTIONARY
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_replacement_patterns'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '22', '40', '51', '58', '70', '81', '88']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '13'], 'value': '+'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'.py'"}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '21'], 'value': '+'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'_models_cltk'"}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'rel_path'}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '36', '37', '38', '39']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'~/cltk_data'"}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'model'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'semantics'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'rel_path'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': "'Loading lemmata or synonyms. This may take a minute.'"}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '61', 'type': 'call', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'importlib'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'machinery'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'SourceFileLoader'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ModuleType'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'exec_module'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'DICTIONARY'}
Check for availability of the specified dictionary.
def _create_child(self, tag): return etree.SubElement(self._root, self._get_namespace_tag(tag))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_child'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'SubElement'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_root'}; {'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_namespace_tag'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tag'}
Create a new child element with the given tag.
def build_rpm(ctx, target): if target not in ('centos6', 'centos7'): print('Error: unknown target "{0}"!'.format(target), file=sys.stderr) sys.exit(1) os.chdir(PROJECT_DIR) rpmbuild_dir = os.path.join(DIST_DIR, 'rpmbuild') ctx.run('mkdir -p {0}'.format(' '.join(os.path.join(rpmbuild_dir, d) for d in ('BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS')))) build_src(ctx, dest=os.path.join(rpmbuild_dir, 'SOURCES')) ctx.run('cp -f {0} {1}'.format(os.path.join(PROJECT_DIR, 'rpm/centos/mssh-copy-id.spec'), os.path.join(rpmbuild_dir, 'SPECS'))) ctx.run('docker run -e LOCAL_USER_ID={local_user_id} -v {local}:{cont} {img}' .format(local_user_id=os.getuid(), local=rpmbuild_dir, cont='/rpmbuild', img=DOCKER_IMGS[target]['name'])) ctx.run('mv -f {0} {1}'.format(os.path.join(rpmbuild_dir, 'RPMS/noarch/mssh-copy-id-*.rpm'), DIST_DIR))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_rpm'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '6', 'type': 'block', 'children': ['7', '36', '43', '55', '88', '104', '133', '164']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'not in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '10', 'type': 'tuple', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'centos6'"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'centos7'"}; {'id': '13', 'type': 'block', 'children': ['14', '29']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '24']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '\'Error: unknown target "{0}"!\''}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'stderr'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'PROJECT_DIR'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'rpmbuild_dir'}; {'id': '46', 'type': 'call', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'DIST_DIR'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'rpmbuild'"}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'mkdir -p {0}'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '70', 'type': 'generator_expression', 'children': ['71', '80']}; {'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': 'join'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'rpmbuild_dir'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '80', 'type': 'for_in_clause', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '82', 'type': 'tuple', 'children': ['83', '84', '85', '86', '87']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'BUILD'"}; {'id': '84', 'type': 'string', 'children': [], 'value': "'RPMS'"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'SOURCES'"}; {'id': '86', 'type': 'string', 'children': [], 'value': "'SPECS'"}; {'id': '87', 'type': 'string', 'children': [], 'value': "'SRPMS'"}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'build_src'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '95', 'type': 'call', 'children': ['96', '101']}; {'id': '96', 'type': 'attribute', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'rpmbuild_dir'}; {'id': '103', 'type': 'string', 'children': [], 'value': "'SOURCES'"}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'cp -f {0} {1}'"}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '124']}; {'id': '115', 'type': 'call', 'children': ['116', '121']}; {'id': '116', 'type': 'attribute', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '121', 'type': 'argument_list', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'PROJECT_DIR'}; {'id': '123', 'type': 'string', 'children': [], 'value': "'rpm/centos/mssh-copy-id.spec'"}; {'id': '124', 'type': 'call', 'children': ['125', '130']}; {'id': '125', 'type': 'attribute', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '130', 'type': 'argument_list', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'rpmbuild_dir'}; {'id': '132', 'type': 'string', 'children': [], 'value': "'SPECS'"}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'string', 'children': [], 'value': "'docker run -e LOCAL_USER_ID={local_user_id} -v {local}:{cont} {img}'"}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '143', 'type': 'argument_list', 'children': ['144', '151', '154', '157']}; {'id': '144', 'type': 'keyword_argument', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'local_user_id'}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'getuid'}; {'id': '150', 'type': 'argument_list', 'children': []}; {'id': '151', 'type': 'keyword_argument', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'rpmbuild_dir'}; {'id': '154', 'type': 'keyword_argument', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'cont'}; {'id': '156', 'type': 'string', 'children': [], 'value': "'/rpmbuild'"}; {'id': '157', 'type': 'keyword_argument', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '159', 'type': 'subscript', 'children': ['160', '163']}; {'id': '160', 'type': 'subscript', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'DOCKER_IMGS'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '163', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '164', 'type': 'expression_statement', 'children': ['165']}; {'id': '165', 'type': 'call', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '169', 'type': 'argument_list', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '174']}; {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'string', 'children': [], 'value': "'mv -f {0} {1}'"}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '174', 'type': 'argument_list', 'children': ['175', '184']}; {'id': '175', 'type': 'call', 'children': ['176', '181']}; {'id': '176', 'type': 'attribute', 'children': ['177', '180']}; {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '181', 'type': 'argument_list', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'rpmbuild_dir'}; {'id': '183', 'type': 'string', 'children': [], 'value': "'RPMS/noarch/mssh-copy-id-*.rpm'"}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'DIST_DIR'}
build an RPM package
def _neighbour_pixels(hp, ipix): neigh_ipix = np.unique(hp.neighbours(ipix).ravel()) return neigh_ipix[np.where(neigh_ipix >= 0)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_neighbour_pixels'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'hp'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ipix'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'neigh_ipix'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'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': 'hp'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'neighbours'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ipix'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ravel'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'neigh_ipix'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': '>='}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'neigh_ipix'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}
Returns all the pixels neighbours of ``ipix``
def unset_env(self, key): os.environ.pop(make_env_key(self.appname, key), None) self._registered_env_keys.discard(key) self._clear_memoization()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unset_env'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'block', 'children': ['7', '23', '32']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '22']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'make_env_key'}; {'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': 'appname'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_registered_env_keys'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'discard'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_clear_memoization'}; {'id': '37', 'type': 'argument_list', 'children': []}
Removes an environment variable using the prepended app_name convention with `key`.
def nextStation(ID, date): jd = eph.nextStation(ID, date.jd) return Datetime.fromJD(jd, date.utcoffset)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nextStation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'date'}; {'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': 'jd'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'eph'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'nextStation'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Datetime'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'fromJD'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'utcoffset'}
Returns the aproximate date of the next station.
def extern_eval(self, context_handle, python_code_str_ptr, python_code_str_len): c = self._ffi.from_handle(context_handle) return self.call(c, eval, [self.to_py_str(python_code_str_ptr, python_code_str_len)])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extern_eval'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'context_handle'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'python_code_str_ptr'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'python_code_str_len'}; {'id': '8', 'type': 'block', 'children': ['9', '20']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_ffi'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'from_handle'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'context_handle'}; {'id': '20', 'type': 'return_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': 'call'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27', '28']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'eval'}; {'id': '28', 'type': 'list', 'children': ['29'], 'value': '[self.to_py_str(python_code_str_ptr, python_code_str_len)]'}; {'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': 'to_py_str'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'python_code_str_ptr'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'python_code_str_len'}
Given an evalable string, eval it and return a Handle for its result.
def add_dependency(self, name, obj): if name in self._deps: if self._deps[name] is obj: return raise ValueError( "There exists a different dep with the same name : %r" % name) self._deps[name] = obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_dependency'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '7', 'type': 'block', 'children': ['8', '32']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_deps'}; {'id': '14', 'type': 'block', 'children': ['15', '25']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '23']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '22'], 'value': 'is'}; {'id': '17', 'type': 'subscript', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_deps'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': []}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '%'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"There exists a different dep with the same name : %r"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '39']}; {'id': '34', 'type': 'subscript', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_deps'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'obj'}
Add a code dependency so it gets inserted into globals
def _map_player_request_to_func(self, player_request_type): view_func = self._intent_view_funcs.get(player_request_type, lambda: None) argspec = inspect.getargspec(view_func) arg_names = argspec.args arg_values = self._map_params_to_view_args(player_request_type, arg_names) return partial(view_func, *arg_values)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_map_player_request_to_func'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'player_request_type'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '29', '35', '45']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'view_func'}; {'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': '_intent_view_funcs'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'player_request_type'}; {'id': '18', 'type': 'lambda', 'children': ['19']}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'argspec'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'getargspec'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'view_func'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'arg_names'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'argspec'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'arg_values'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_map_params_to_view_args'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'player_request_type'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'arg_names'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'view_func'}; {'id': '50', 'type': 'list_splat', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'arg_values'}
Provides appropriate parameters to the on_playback functions.
def _get_json(self, url): "Get JSON-type content" content = self._get_content('jsonds/' + url) try: json_content = json.loads(content.decode()) except AttributeError: json_content = json.loads(content) if json_content['Comment']: log.warning(json_content['Comment']) if json_content['Result'] != 'OK': raise ValueError('Error while retrieving the parameter list.') return json_content['Data']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '20', '47', '61', '73']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Get JSON-type content"'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_get_content'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '19'], 'value': '+'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'jsonds/'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'try_statement', 'children': ['21', '35']}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'json_content'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'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': 'content'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'except_clause', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'json_content'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '51']}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'json_content'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'Comment'"}; {'id': '51', 'type': 'block', 'children': ['52']}; {'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': 'log'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'json_content'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'Comment'"}; {'id': '61', 'type': 'if_statement', 'children': ['62', '67']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '66'], 'value': '!='}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'json_content'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'Result'"}; {'id': '66', 'type': 'string', 'children': [], 'value': "'OK'"}; {'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': 'ValueError'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'Error while retrieving the parameter list.'"}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'json_content'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'Data'"}
Get JSON-type content
def clear_sessions(venv=None): if "VIRTUAL_ENV" in os.environ: ve = os.path.basename(os.environ["VIRTUAL_ENV"]) else: ve = "" if venv is not None: ve = venv else: ve = prompt("Enter the name of the " "sandbox whose sessions you would like to delete, or " "\"ion\" to clear production sessions:", default=ve) c = "redis-cli -n {0} KEYS {1}:session:* | sed 's/\"^.*\")//g'" keys_command = c.format(REDIS_SESSION_DB, ve) keys = local(keys_command, capture=True) count = 0 if keys.strip() == "" else keys.count("\n") + 1 if count == 0: puts("No sessions to destroy.") return 0 plural = "s" if count != 1 else "" if not confirm("Are you sure you want to destroy {} {}" "session{}?".format(count, "production " if ve == "ion" else "", plural)): return 0 if count > 0: local("{0}| xargs redis-cli -n " "{1} DEL".format(keys_command, REDIS_SESSION_DB)) puts("Destroyed {} session{}.".format(count, plural))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_sessions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'venv'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '36', '60', '64', '74', '84', '104', '116', '125', '148']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14', '30']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"VIRTUAL_ENV"'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 've'}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"VIRTUAL_ENV"'}; {'id': '30', 'type': 'else_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 've'}; {'id': '35', 'type': 'string', 'children': [], 'value': '""'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40', '45']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'is not'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'venv'}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 've'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'venv'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 've'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'prompt'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '57']}; {'id': '53', 'type': 'concatenated_string', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'string', 'children': [], 'value': '"Enter the name of the "'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"sandbox whose sessions you would like to delete, or "'}; {'id': '56', 'type': 'string', 'children': [], 'value': '"\\"ion\\" to clear production sessions:"'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 've'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '63', 'type': 'string', 'children': [], 'value': '"redis-cli -n {0} KEYS {1}:session:* | sed \'s/\\"^.*\\")//g\'"'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'keys_command'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'REDIS_SESSION_DB'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 've'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'keys_command'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'capture'}; {'id': '83', 'type': 'True', 'children': []}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '87', 'type': 'conditional_expression', 'children': ['88', '89', '96'], 'value': 'if'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '95'], 'value': '=='}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '94', 'type': 'argument_list', 'children': []}; {'id': '95', 'type': 'string', 'children': [], 'value': '""'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '103'], 'value': '+'}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'if_statement', 'children': ['105', '108']}; {'id': '105', 'type': 'comparison_operator', 'children': ['106', '107'], 'value': '=='}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '107', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '108', 'type': 'block', 'children': ['109', '114']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'puts'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'string', 'children': [], 'value': '"No sessions to destroy."'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'plural'}; {'id': '119', 'type': 'conditional_expression', 'children': ['120', '121', '124'], 'value': 'if'}; {'id': '120', 'type': 'string', 'children': [], 'value': '"s"'}; {'id': '121', 'type': 'comparison_operator', 'children': ['122', '123'], 'value': '!='}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '123', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '124', 'type': 'string', 'children': [], 'value': '""'}; {'id': '125', 'type': 'if_statement', 'children': ['126', '145']}; {'id': '126', 'type': 'not_operator', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'confirm'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '136']}; {'id': '131', 'type': 'attribute', 'children': ['132', '135']}; {'id': '132', 'type': 'concatenated_string', 'children': ['133', '134']}; {'id': '133', 'type': 'string', 'children': [], 'value': '"Are you sure you want to destroy {} {}"'}; {'id': '134', 'type': 'string', 'children': [], 'value': '"session{}?"'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '136', 'type': 'argument_list', 'children': ['137', '138', '144']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '138', 'type': 'conditional_expression', 'children': ['139', '140', '143'], 'value': 'if'}; {'id': '139', 'type': 'string', 'children': [], 'value': '"production "'}; {'id': '140', 'type': 'comparison_operator', 'children': ['141', '142'], 'value': '=='}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 've'}; {'id': '142', 'type': 'string', 'children': [], 'value': '"ion"'}; {'id': '143', 'type': 'string', 'children': [], 'value': '""'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'plural'}; {'id': '145', 'type': 'block', 'children': ['146']}; {'id': '146', 'type': 'return_statement', 'children': ['147']}; {'id': '147', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '148', 'type': 'if_statement', 'children': ['149', '152']}; {'id': '149', 'type': 'comparison_operator', 'children': ['150', '151'], 'value': '>'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '151', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '152', 'type': 'block', 'children': ['153', '166']}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '163']}; {'id': '158', 'type': 'attribute', 'children': ['159', '162']}; {'id': '159', 'type': 'concatenated_string', 'children': ['160', '161']}; {'id': '160', 'type': 'string', 'children': [], 'value': '"{0}| xargs redis-cli -n "'}; {'id': '161', 'type': 'string', 'children': [], 'value': '"{1} DEL"'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '163', 'type': 'argument_list', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'keys_command'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'REDIS_SESSION_DB'}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}; {'id': '167', 'type': 'call', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'puts'}; {'id': '169', 'type': 'argument_list', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '174']}; {'id': '171', 'type': 'attribute', 'children': ['172', '173']}; {'id': '172', 'type': 'string', 'children': [], 'value': '"Destroyed {} session{}."'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '174', 'type': 'argument_list', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'plural'}
Clear all sessions for all sandboxes or for production.
def unit_type(scale=None): palette_size = scale or max(static_data.UNIT_TYPES) + 1 palette = shuffled_hue(palette_size) assert len(static_data.UNIT_TYPES) <= len(distinct_colors) for i, v in enumerate(static_data.UNIT_TYPES): palette[v] = distinct_colors[i] return palette
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unit_type'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '21', '28', '40', '59']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'palette_size'}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '13'], 'value': 'or'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'scale'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '20'], 'value': '+'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'static_data'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'UNIT_TYPES'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'palette'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'shuffled_hue'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'palette_size'}; {'id': '28', 'type': 'assert_statement', 'children': ['29']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '36'], 'value': '<='}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'static_data'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'UNIT_TYPES'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'distinct_colors'}; {'id': '40', 'type': 'for_statement', 'children': ['41', '44', '50']}; {'id': '41', 'type': 'pattern_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'static_data'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'UNIT_TYPES'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '56']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'palette'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'distinct_colors'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'palette'}
Returns a palette that maps unit types to rgb colors.
def dispatch(self, category, func, *args): self.factory.loader.runPlugins(category, func, self, *args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '7', 'type': 'list_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'factory'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'runPlugins'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22', '23']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'list_splat', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'args'}
Dispatch an event to all listening plugins.
def on(self): msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, X10_COMMAND_ON) self._send_method(msg, False) self._update_subscribers(0xff)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '31', '45', '53']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'X10Send'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'unit_code_msg'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'x10_housecode'}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'x10_unitcode'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_send_method'}; {'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': 'msg'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'X10Send'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'command_msg'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'x10_housecode'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'X10_COMMAND_ON'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_send_method'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '52', 'type': 'False', 'children': []}; {'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': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_update_subscribers'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0xff'}
Send the On command to an X10 device.
def _track_from_response(result, timeout): response = result['response'] status = response['track']['status'].lower() if status == 'pending': result = _wait_for_pending_track(response['track']['id'], timeout) response = result['response'] status = response['track']['status'].lower() if not status == 'complete': track_id = response['track']['id'] if status == 'pending': raise Exception('%s: the operation didn\'t complete before the timeout (%d secs)' % (track_id, timeout)) else: raise Exception('%s: there was an error analyzing the track, status: %s' % (track_id, status)) else: track_properties = response['track'] identifier = track_properties.pop('id') md5 = track_properties.pop('md5', None) track_properties.update(track_properties.pop('audio_summary')) return Track(identifier, md5, track_properties)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_track_from_response'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '25', '60']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'response'"}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '16', 'type': 'call', 'children': ['17', '24']}; {'id': '17', 'type': 'attribute', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'track'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': '=='}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'pending'"}; {'id': '29', 'type': 'block', 'children': ['30', '42', '48']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_wait_for_pending_track'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '41']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'track'"}; {'id': '40', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'response'"}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '51', 'type': 'call', 'children': ['52', '59']}; {'id': '52', 'type': 'attribute', 'children': ['53', '58']}; {'id': '53', 'type': 'subscript', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'track'"}; {'id': '57', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'if_statement', 'children': ['61', '65', '99']}; {'id': '61', 'type': 'not_operator', 'children': ['62']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': '=='}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'complete'"}; {'id': '65', 'type': 'block', 'children': ['66', '74']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'track_id'}; {'id': '69', 'type': 'subscript', 'children': ['70', '73']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'track'"}; {'id': '73', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '74', 'type': 'if_statement', 'children': ['75', '78', '88']}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '77'], 'value': '=='}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'pending'"}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'raise_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '%'}; {'id': '84', 'type': 'string', 'children': [], 'value': "'%s: the operation didn\\'t complete before the timeout (%d secs)'"}; {'id': '85', 'type': 'tuple', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'track_id'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '88', 'type': 'else_clause', 'children': ['89']}; {'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': 'Exception'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '96'], 'value': '%'}; {'id': '95', 'type': 'string', 'children': [], 'value': "'%s: there was an error analyzing the track, status: %s'"}; {'id': '96', 'type': 'tuple', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'track_id'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '99', 'type': 'else_clause', 'children': ['100']}; {'id': '100', 'type': 'block', 'children': ['101', '107', '116', '126', '138']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'track_properties'}; {'id': '104', 'type': 'subscript', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '106', 'type': 'string', 'children': [], 'value': "'track'"}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'track_properties'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'track_properties'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '123', 'type': 'argument_list', 'children': ['124', '125']}; {'id': '124', 'type': 'string', 'children': [], 'value': "'md5'"}; {'id': '125', 'type': 'None', 'children': []}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'track_properties'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'track_properties'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'string', 'children': [], 'value': "'audio_summary'"}; {'id': '138', 'type': 'return_statement', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'Track'}; {'id': '141', 'type': 'argument_list', 'children': ['142', '143', '144']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'md5'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'track_properties'}
This is the function that actually creates the track object
def _print_breakdown(cls, savedir, fname, data): if not os.path.exists(savedir): os.makedirs(savedir) with open(os.path.join(savedir, fname), 'w') as fout: fout.write(data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_print_breakdown'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'savedir'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '8', 'type': 'block', 'children': ['9', '27']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '19']}; {'id': '10', 'type': 'not_operator', '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': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'savedir'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'savedir'}; {'id': '27', 'type': 'with_statement', 'children': ['28', '46']}; {'id': '28', 'type': 'with_clause', 'children': ['29']}; {'id': '29', 'type': 'with_item', 'children': ['30']}; {'id': '30', 'type': 'as_pattern', 'children': ['31', '44']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '43']}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'savedir'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '44', 'type': 'as_pattern_target', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fout'}; {'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': 'fout'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'data'}
Function to print model fixtures into generated file
def from_python_file( cls, python_file, lambdas_path, json_filename: str, stem: str ): with open(python_file, "r") as f: pySrc = f.read() return cls.from_python_src(pySrc, lambdas_path, json_filename, stem)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_python_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'python_file'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'lambdas_path'}; {'id': '7', 'type': 'typed_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'json_filename'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '11', 'type': 'typed_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stem'}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'block', 'children': ['16', '36']}; {'id': '16', 'type': 'with_statement', 'children': ['17', '27']}; {'id': '17', 'type': 'with_clause', 'children': ['18']}; {'id': '18', 'type': 'with_item', 'children': ['19']}; {'id': '19', 'type': 'as_pattern', 'children': ['20', '25']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'python_file'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"r"'}; {'id': '25', 'type': 'as_pattern_target', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'f'}; {'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': 'pySrc'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'from_python_src'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43', '44', '45']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pySrc'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'lambdas_path'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'json_filename'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'stem'}
Builds GrFN object from Python file.
def new_nodes_allowed_for_layer(self): if not self.pk and self.layer and not self.layer.new_nodes_allowed: raise ValidationError(_('New nodes are not allowed for this layer'))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'new_nodes_allowed_for_layer'}; {'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', '22']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '16'], 'value': 'and'}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '13'], 'value': 'and'}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'layer'}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'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': 'layer'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'new_nodes_allowed'}; {'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': 'ValidationError'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'New nodes are not allowed for this layer'"}
ensure new nodes are allowed for this layer
def _get_os_price_id(items, os, location): for item in items: if any([utils.lookup(item, 'itemCategory', 'categoryCode') != 'os', utils.lookup(item, 'softwareDescription', 'referenceCode') != os]): continue for price in item['prices']: if not _matches_location(price, location): continue return price['id'] raise SoftLayer.SoftLayerError("Could not find valid price for os: '%s'" % os)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_os_price_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '7', 'type': 'block', 'children': ['8', '58']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '11', 'type': 'block', 'children': ['12', '39']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '37']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'list', 'children': ['17', '27'], 'value': "[utils.lookup(item,\n 'itemCategory',\n 'categoryCode') != 'os',\n utils.lookup(item,\n 'softwareDescription',\n 'referenceCode') != os]"}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '26'], 'value': '!='}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'lookup'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'itemCategory'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "'categoryCode'"}; {'id': '26', 'type': 'string', 'children': [], 'value': "'os'"}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '36'], 'value': '!='}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'lookup'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'softwareDescription'"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'referenceCode'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'continue_statement', 'children': []}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '44']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'prices'"}; {'id': '44', 'type': 'block', 'children': ['45', '54']}; {'id': '45', 'type': 'if_statement', 'children': ['46', '52']}; {'id': '46', 'type': 'not_operator', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_matches_location'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'continue_statement', 'children': []}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'price'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '58', 'type': 'raise_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'SoftLayer'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'SoftLayerError'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'binary_operator', 'children': ['65', '66'], 'value': '%'}; {'id': '65', 'type': 'string', 'children': [], 'value': '"Could not find valid price for os: \'%s\'"'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'os'}
Returns the price id matching.
def chao_shen(q): yx = q[q > 0] n = np.sum(yx) p = yx.astype(float)/n f1 = np.sum(yx == 1) if f1 == n: f1 -= 1 C = 1 - (f1/n) pa = C * p la = (1 - (1 - pa) ** n) H = -np.sum((pa * np.log2(pa)) / la) return (H, pa, la)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chao_shen'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '23', '34', '45', '54', '63', '69', '81', '101']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'yx'}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': '>'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'yx'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '33'], 'value': '/'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'yx'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'astype'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'f1'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': '=='}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'yx'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': '=='}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'f1'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'augmented_assignment', 'children': ['52', '53'], 'value': '-='}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'f1'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '57', 'type': 'binary_operator', 'children': ['58', '59'], 'value': '-'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '59', 'type': '()', 'children': ['60']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '/'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'f1'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'pa'}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '68'], 'value': '*'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'la'}; {'id': '72', 'type': '()', 'children': ['73']}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '75'], 'value': '-'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '80'], 'value': '**'}; {'id': '76', 'type': '()', 'children': ['77']}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '79'], 'value': '-'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'pa'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'H'}; {'id': '84', 'type': 'unary_operator', 'children': ['85'], 'value': '-'}; {'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': 'sum'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '100'], 'value': '/'}; {'id': '91', 'type': '()', 'children': ['92']}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '94'], 'value': '*'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'pa'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'log2'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'pa'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'la'}; {'id': '101', 'type': 'return_statement', 'children': ['102']}; {'id': '102', 'type': 'tuple', 'children': ['103', '104', '105']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'H'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'pa'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'la'}
Computes some terms needed for the Chao-Shen KL correction.
def interrupt(self, interrupt): self._interrupt = True self.stop() self._interrupt = interrupt
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interrupt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'interrupt'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19']}; {'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': '_interrupt'}; {'id': '12', 'type': 'True', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_interrupt'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'interrupt'}
Perform the shutdown of this server and save the exception.
def flatten_dict(self, obj): return OrderedDict(zip(self.fieldnames, self.flatten(obj)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'fieldnames'}; {'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': 'flatten'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'obj'}
Return an OrderedDict dict preserving order of keys in fieldnames
def overlap(self, other): if self._start < other.end and self._end > other.start: return True return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'overlap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '6', 'type': 'block', 'children': ['7', '26']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '23']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '16'], 'value': 'and'}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '13'], 'value': '<'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_start'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': '>'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_end'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'True', 'children': []}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'False', 'children': []}
Determine whether this range overlaps with another.
def list(self, where): if where == 'pillar': schedule = self._get_schedule(include_opts=False) elif where == 'opts': schedule = self._get_schedule(include_pillar=False) else: schedule = self._get_schedule() evt = salt.utils.event.get_event('minion', opts=self.opts, listen=False) evt.fire_event({'complete': True, 'schedule': schedule}, tag='/salt/minion/minion_schedule_list_complete')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '6', 'type': 'block', 'children': ['7', '49', '70']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11', '23', '39']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '=='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'pillar'"}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'schedule'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_get_schedule'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'include_opts'}; {'id': '22', 'type': 'False', 'children': []}; {'id': '23', 'type': 'elif_clause', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': '=='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'opts'"}; {'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': 'schedule'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_get_schedule'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'include_pillar'}; {'id': '38', 'type': 'False', 'children': []}; {'id': '39', 'type': 'else_clause', 'children': ['40']}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'schedule'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_get_schedule'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'evt'}; {'id': '52', 'type': 'call', 'children': ['53', '60']}; {'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': 'salt'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'get_event'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '67']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'minion'"}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'listen'}; {'id': '69', 'type': 'False', 'children': []}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'evt'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'fire_event'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '83']}; {'id': '76', 'type': 'dictionary', 'children': ['77', '80']}; {'id': '77', 'type': 'pair', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'complete'"}; {'id': '79', 'type': 'True', 'children': []}; {'id': '80', 'type': 'pair', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': "'schedule'"}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'schedule'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'/salt/minion/minion_schedule_list_complete'"}
List the current schedule items
def count(cls, user_id): return cls.query.with_entities( cls.user_id).filter_by(user_id=user_id).count()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '28']}; {'id': '9', 'type': 'attribute', 'children': ['10', '27']}; {'id': '10', 'type': 'call', 'children': ['11', '23']}; {'id': '11', 'type': 'attribute', 'children': ['12', '22']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'with_entities'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'filter_by'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '28', 'type': 'argument_list', 'children': []}
Count sessions with user_id
def _bottom(self): _, top, _, height = self._extents return top + height
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_bottom'}; {'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', '13']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10', '11', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_extents'}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '19'], 'value': '+'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'height'}
Index of row following last row of range
def sqrt(self, val, flag): if val.iszero(): return val sw = self.p % 8 if sw == 3 or sw == 7: res = val ** ((self.p + 1) / 4) elif sw == 5: x = val ** ((self.p + 1) / 4) if x == 1: res = val ** ((self.p + 3) / 8) else: res = (4 * val) ** ((self.p - 5) / 8) * 2 * val else: raise Exception("modsqrt non supported for (p%8)==1") if res.value % 2 == flag: return res else: return -res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sqrt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '25', '116']}; {'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': 'val'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'iszero'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sw'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '24'], 'value': '%'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '33', '48', '109']}; {'id': '26', 'type': 'boolean_operator', 'children': ['27', '30'], 'value': 'or'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': '=='}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sw'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '=='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sw'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '7'}; {'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': 'res'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '**'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '39', 'type': '()', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '47'], 'value': '/'}; {'id': '41', 'type': '()', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '46'], 'value': '+'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '48', 'type': 'elif_clause', 'children': ['49', '52']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': '=='}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'sw'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '52', 'type': 'block', 'children': ['53', '67']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '**'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '58', 'type': '()', 'children': ['59']}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '66'], 'value': '/'}; {'id': '60', 'type': '()', 'children': ['61']}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '65'], 'value': '+'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '67', 'type': 'if_statement', 'children': ['68', '71', '86']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': '=='}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '**'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '77', 'type': '()', 'children': ['78']}; {'id': '78', 'type': 'binary_operator', 'children': ['79', '85'], 'value': '/'}; {'id': '79', 'type': '()', 'children': ['80']}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '84'], 'value': '+'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '86', 'type': 'else_clause', 'children': ['87']}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '108'], 'value': '*'}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '107'], 'value': '*'}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '98'], 'value': '**'}; {'id': '94', 'type': '()', 'children': ['95']}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '97'], 'value': '*'}; {'id': '96', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '98', 'type': '()', 'children': ['99']}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '106'], 'value': '/'}; {'id': '100', 'type': '()', 'children': ['101']}; {'id': '101', 'type': 'binary_operator', 'children': ['102', '105'], 'value': '-'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '107', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '109', 'type': 'else_clause', 'children': ['110']}; {'id': '110', 'type': 'block', 'children': ['111']}; {'id': '111', 'type': 'raise_statement', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'string', 'children': [], 'value': '"modsqrt non supported for (p%8)==1"'}; {'id': '116', 'type': 'if_statement', 'children': ['117', '124', '127']}; {'id': '117', 'type': 'comparison_operator', 'children': ['118', '123'], 'value': '=='}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '122'], 'value': '%'}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '122', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'return_statement', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '127', 'type': 'else_clause', 'children': ['128']}; {'id': '128', 'type': 'block', 'children': ['129']}; {'id': '129', 'type': 'return_statement', 'children': ['130']}; {'id': '130', 'type': 'unary_operator', 'children': ['131'], 'value': '-'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'res'}
calculate the square root modulus p
def addRectAnnot(self, rect): CheckParent(self) val = _fitz.Page_addRectAnnot(self, rect) if not val: return val.thisown = True val.parent = weakref.proxy(self) self._annot_refs[id(val)] = val return val
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addRectAnnot'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rect'}; {'id': '6', 'type': 'block', 'children': ['7', '12', '22', '27', '33', '44', '55']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'CheckParent'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_fitz'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Page_addRectAnnot'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rect'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '25']}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': []}; {'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': 'val'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'thisown'}; {'id': '32', 'type': 'True', 'children': []}; {'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': 'val'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'weakref'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '54']}; {'id': '46', 'type': 'subscript', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_annot_refs'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'val'}
Add a 'Rectangle' annotation.
def deserialize_instance(model, data={}): "Translate raw data into a model instance." ret = model() for k, v in data.items(): if v is not None: try: f = model._meta.get_field(k) if isinstance(f, DateTimeField): v = dateparse.parse_datetime(v) elif isinstance(f, TimeField): v = dateparse.parse_time(v) elif isinstance(f, DateField): v = dateparse.parse_date(v) except FieldDoesNotExist: pass setattr(ret, k, v) return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deserialize_instance'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '7', 'type': 'dictionary', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '11', '17', '104']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"Translate raw data into a model instance."'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'for_statement', 'children': ['18', '21', '26']}; {'id': '18', 'type': 'pattern_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27', '97']}; {'id': '27', 'type': 'if_statement', 'children': ['28', '31']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '30'], 'value': 'is not'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'try_statement', 'children': ['33', '93']}; {'id': '33', 'type': 'block', 'children': ['34', '45']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'f'}; {'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': 'model'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get_field'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '51', '61', '77']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'DateTimeField'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'dateparse'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'parse_datetime'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '61', 'type': 'elif_clause', 'children': ['62', '67']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'TimeField'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'dateparse'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'parse_time'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '77', 'type': 'elif_clause', 'children': ['78', '83']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'DateField'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'dateparse'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'parse_date'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '93', 'type': 'except_clause', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'FieldDoesNotExist'}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'pass_statement', 'children': []}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '102', '103']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'ret'}
Translate raw data into a model instance.
def run_cell_magic(self, magic_name, line, cell): if magic_name == 'bash': self.shebang("bash", cell) elif magic_name == 'metatab': self.mm.metatab(line, cell)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_cell_magic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'magic_name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13', '22']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': '=='}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'magic_name'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'bash'"}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'shebang'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"bash"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '22', 'type': 'elif_clause', 'children': ['23', '26']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': '=='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'magic_name'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'metatab'"}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'mm'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'metatab'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cell'}
Run a limited number of magics from scripts, without IPython
def provider_factory(provider, **options): try: return {"tmdb": TMDb, "tvdb": TVDb}[provider.lower()](**options) except KeyError: msg = "Attempted to initialize non-existing DB Provider" log.error(msg) raise MapiException(msg)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'provider_factory'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '28']}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '25']}; {'id': '12', 'type': 'subscript', 'children': ['13', '20']}; {'id': '13', 'type': 'dictionary', 'children': ['14', '17']}; {'id': '14', 'type': 'pair', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"tmdb"'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'TMDb'}; {'id': '17', 'type': 'pair', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"tvdb"'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'TVDb'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'dictionary_splat', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '28', 'type': 'except_clause', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '30', 'type': 'block', 'children': ['31', '35', '42']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"Attempted to initialize non-existing DB Provider"'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '42', 'type': 'raise_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'MapiException'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'msg'}
Factory function for DB Provider Concrete Classes
def update_type(self, request, *args, **kwargs): self.object = self.get_object() success_url = self.get_success_url() self.object.type = self.target_type self.object.save() messages.success(self.request, self.success_message) return HttpResponseRedirect(success_url)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'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', '21', '29', '39', '47', '59']}; {'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': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'object'}; {'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_object'}; {'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': 'success_url'}; {'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_success_url'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', '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': 'object'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'target_type'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'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': 'messages'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'success_message'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'HttpResponseRedirect'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'success_url'}
Updates the type of the considered topic and retirects the user to the success URL.
def GetMostRecentClient(client_list, token=None): last = rdfvalue.RDFDatetime(0) client_urn = None for client in aff4.FACTORY.MultiOpen(client_list, token=token): client_last = client.Get(client.Schema.LAST) if client_last > last: last = client_last client_urn = client.urn return client_urn
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetMostRecentClient'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'client_list'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '18', '22', '64']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'rdfvalue'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'RDFDatetime'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'client_urn'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '35']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'client'}; {'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': 'aff4'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'FACTORY'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'MultiOpen'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'client_list'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '35', 'type': 'block', 'children': ['36', '49']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'client_last'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'Get'}; {'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': 'client'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'Schema'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'LAST'}; {'id': '49', 'type': 'if_statement', 'children': ['50', '53']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': '>'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'client_last'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '53', 'type': 'block', 'children': ['54', '58']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'last'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'client_last'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'client_urn'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'urn'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'client_urn'}
Return most recent client from list of clients.
def compare(self, path, prefixed_path, source_storage): comparitor = getattr(self, 'compare_%s' % self.comparison_method, None) if not comparitor: comparitor = self._create_comparitor(self.comparison_method) return comparitor(path, prefixed_path, source_storage)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compare'}; {'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': 'prefixed_path'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'source_storage'}; {'id': '8', 'type': 'block', 'children': ['9', '22', '37']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'comparitor'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '%'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'compare_%s'"}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'comparison_method'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '25']}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'comparitor'}; {'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': 'comparitor'}; {'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': '_create_comparitor'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'comparison_method'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'comparitor'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42', '43']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'prefixed_path'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'source_storage'}
Returns True if the file should be copied.
def _Reg2Py(data, size, data_type): if data_type == winreg.REG_DWORD: if size == 0: return 0 return ctypes.cast(data, ctypes.POINTER(ctypes.c_uint32)).contents.value elif data_type == winreg.REG_SZ or data_type == winreg.REG_EXPAND_SZ: return ctypes.wstring_at(data, size // 2).rstrip(u"\x00") elif data_type == winreg.REG_MULTI_SZ: return ctypes.wstring_at(data, size // 2).rstrip(u"\x00").split(u"\x00") else: if size == 0: return None return ctypes.string_at(data, size)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_Reg2Py'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14', '41', '69', '96']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': '=='}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'winreg'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'REG_DWORD'}; {'id': '14', 'type': 'block', 'children': ['15', '22']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '=='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '40']}; {'id': '24', 'type': 'attribute', 'children': ['25', '39']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cast'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'POINTER'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'c_uint32'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '41', 'type': 'elif_clause', 'children': ['42', '53']}; {'id': '42', 'type': 'boolean_operator', 'children': ['43', '48'], 'value': 'or'}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': '=='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'winreg'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'REG_SZ'}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': '=='}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'winreg'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'REG_EXPAND_SZ'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '67']}; {'id': '56', 'type': 'attribute', 'children': ['57', '66']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'wstring_at'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '//'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'string', 'children': [], 'value': 'u"\\x00"'}; {'id': '69', 'type': 'elif_clause', 'children': ['70', '75']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '72'], 'value': '=='}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'winreg'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'REG_MULTI_SZ'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '94']}; {'id': '78', 'type': 'attribute', 'children': ['79', '93']}; {'id': '79', 'type': 'call', 'children': ['80', '91']}; {'id': '80', 'type': 'attribute', 'children': ['81', '90']}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'wstring_at'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '87', 'type': 'binary_operator', 'children': ['88', '89'], 'value': '//'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'rstrip'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'string', 'children': [], 'value': 'u"\\x00"'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'string', 'children': [], 'value': 'u"\\x00"'}; {'id': '96', 'type': 'else_clause', 'children': ['97']}; {'id': '97', 'type': 'block', 'children': ['98', '105']}; {'id': '98', 'type': 'if_statement', 'children': ['99', '102']}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '101'], 'value': '=='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'None', 'children': []}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'string_at'}; {'id': '110', 'type': 'argument_list', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'size'}
Converts a Windows Registry value to the corresponding Python data type.
def disconnect(self, sid, namespace): if namespace not in self.rooms: return rooms = [] for room_name, room in six.iteritems(self.rooms[namespace].copy()): if sid in room: rooms.append(room_name) for room in rooms: self.leave_room(sid, namespace, room) if sid in self.callbacks and namespace in self.callbacks[sid]: del self.callbacks[sid][namespace] if len(self.callbacks[sid]) == 0: del self.callbacks[sid] if namespace in self.pending_disconnect and \ sid in self.pending_disconnect[namespace]: self.pending_disconnect[namespace].remove(sid) if len(self.pending_disconnect[namespace]) == 0: del self.pending_disconnect[namespace]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'disconnect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '20', '51', '64', '105']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'not in'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'rooms'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rooms'}; {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'for_statement', 'children': ['21', '24', '38']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'room_name'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'room'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '37']}; {'id': '30', 'type': 'attribute', 'children': ['31', '36']}; {'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': 'rooms'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'if_statement', 'children': ['40', '43']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'in'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'room'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'rooms'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'room_name'}; {'id': '51', 'type': 'for_statement', 'children': ['52', '53', '54']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'room'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'rooms'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'leave_room'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'room'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '78']}; {'id': '65', 'type': 'boolean_operator', 'children': ['66', '71'], 'value': 'and'}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '68'], 'value': 'in'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'callbacks'}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'in'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '73', 'type': 'subscript', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'callbacks'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '78', 'type': 'block', 'children': ['79', '87']}; {'id': '79', 'type': 'delete_statement', 'children': ['80']}; {'id': '80', 'type': 'subscript', 'children': ['81', '86']}; {'id': '81', 'type': 'subscript', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'callbacks'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '87', 'type': 'if_statement', 'children': ['88', '98']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '97'], 'value': '=='}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'subscript', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'callbacks'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '97', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'delete_statement', 'children': ['100']}; {'id': '100', 'type': 'subscript', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'callbacks'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '120']}; {'id': '106', 'type': 'boolean_operator', 'children': ['107', '112', '113'], 'value': 'and'}; {'id': '107', 'type': 'comparison_operator', 'children': ['108', '109'], 'value': 'in'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'pending_disconnect'}; {'id': '112', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '113', 'type': 'comparison_operator', 'children': ['114', '115'], 'value': 'in'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '115', 'type': 'subscript', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'pending_disconnect'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '120', 'type': 'block', 'children': ['121', '132']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '130']}; {'id': '123', 'type': 'attribute', 'children': ['124', '129']}; {'id': '124', 'type': 'subscript', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'pending_disconnect'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'sid'}; {'id': '132', 'type': 'if_statement', 'children': ['133', '143']}; {'id': '133', 'type': 'comparison_operator', 'children': ['134', '142'], 'value': '=='}; {'id': '134', 'type': 'call', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'subscript', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'pending_disconnect'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '142', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '143', 'type': 'block', 'children': ['144']}; {'id': '144', 'type': 'delete_statement', 'children': ['145']}; {'id': '145', 'type': 'subscript', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'pending_disconnect'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'namespace'}
Register a client disconnect from a namespace.
def from_file(cls, filepath): with open(filepath, "rt") as fh: return cls(**yaml.safe_load(fh))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'as_pattern', 'children': ['11', '16']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"rt"'}; {'id': '16', 'type': 'as_pattern_target', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fh'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'dictionary_splat', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'safe_load'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'fh'}
Read the configuration parameters from a Yaml file.
def managepy(cmd, extra=None): extra = extra.split() if extra else [] run_django_cli(['invoke', cmd] + extra)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'managepy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '20']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '12', 'type': 'conditional_expression', 'children': ['13', '18', '19'], 'value': 'if'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'run_django_cli'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '28'], 'value': '+'}; {'id': '25', 'type': 'list', 'children': ['26', '27'], 'value': "['invoke', cmd]"}; {'id': '26', 'type': 'string', 'children': [], 'value': "'invoke'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'extra'}
Run manage.py using this component's specific Django settings
def _bucket_exists(self): try: self.s3client.get_bucket_location(Bucket=self.bucket) return True except ClientError as error: LOG.error(error) return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_bucket_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '23']}; {'id': '7', 'type': 'block', 'children': ['8', '21']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 's3client'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_bucket_location'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Bucket'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'True', 'children': []}; {'id': '23', 'type': 'except_clause', 'children': ['24', '28']}; {'id': '24', 'type': 'as_pattern', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ClientError'}; {'id': '26', 'type': 'as_pattern_target', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '28', 'type': 'block', 'children': ['29', '36']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'LOG'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'False', 'children': []}
Check if the bucket exists.
def mda_count(self): self.open() mda = lvm_pv_get_mda_count(self.handle) self.close() return mda
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mda_count'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '21', '27']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'open'}; {'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': 'mda'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lvm_pv_get_mda_count'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'mda'}
Returns the physical volume mda count.
def _open_connection(self): if self._scheme == 'unix': self._connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) self._connection.connect(self._path) elif self._scheme == 'tcp': self._connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP) self._connection.connect((self._host, self._port)) elif self._scheme == 'http': self._connection = httplib.HTTPConnection(self._host, self._port, strict=False) else: raise ConnectionError("Connection scheme not recognized!")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_open_connection'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '41', '82', '108']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_scheme'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'unix'"}; {'id': '12', 'type': 'block', 'children': ['13', '30']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26', '29']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'AF_UNIX'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'SOCK_STREAM'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_path'}; {'id': '41', 'type': 'elif_clause', 'children': ['42', '47']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '46'], 'value': '=='}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_scheme'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'tcp'"}; {'id': '47', 'type': 'block', 'children': ['48', '67']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '61', '64']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'AF_INET'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'SOCK_STREAM'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'SOL_TCP'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'tuple', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_host'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': '_port'}; {'id': '82', 'type': 'elif_clause', 'children': ['83', '88']}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '87'], 'value': '=='}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_scheme'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'http'"}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'httplib'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'HTTPConnection'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '102', '105']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': '_host'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_port'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'strict'}; {'id': '107', 'type': 'False', 'children': []}; {'id': '108', 'type': 'else_clause', 'children': ['109']}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'raise_statement', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'ConnectionError'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'string', 'children': [], 'value': '"Connection scheme not recognized!"'}
Open a new connection socket to the CPS.
def pages_admin_menu(context, page): request = context.get('request', None) expanded = False if request and "tree_expanded" in request.COOKIES: cookie_string = urllib.unquote(request.COOKIES['tree_expanded']) if cookie_string: ids = [int(id) for id in urllib.unquote(request.COOKIES['tree_expanded']).split(',')] if page.id in ids: expanded = True context.update({'expanded': expanded, 'page': page}) return context
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pages_admin_menu'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '21', '82', '95']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'request'"}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'expanded'}; {'id': '20', 'type': 'False', 'children': []}; {'id': '21', 'type': 'if_statement', 'children': ['22', '29']}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '24'], 'value': 'and'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'in'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"tree_expanded"'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'COOKIES'}; {'id': '29', 'type': 'block', 'children': ['30', '43']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cookie_string'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'urllib'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'unquote'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'COOKIES'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'tree_expanded'"}; {'id': '43', 'type': 'if_statement', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cookie_string'}; {'id': '45', 'type': 'block', 'children': ['46', '71']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '49', 'type': 'list_comprehension', 'children': ['50', '54']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '56', 'type': 'call', 'children': ['57', '69']}; {'id': '57', 'type': 'attribute', 'children': ['58', '68']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'urllib'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'unquote'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'COOKIES'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'tree_expanded'"}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': "','"}; {'id': '71', 'type': 'if_statement', 'children': ['72', '77']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '76'], 'value': 'in'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'expanded'}; {'id': '81', 'type': 'True', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'dictionary', 'children': ['89', '92']}; {'id': '89', 'type': 'pair', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': "'expanded'"}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'expanded'}; {'id': '92', 'type': 'pair', 'children': ['93', '94']}; {'id': '93', 'type': 'string', 'children': [], 'value': "'page'"}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'context'}
Render the admin table of pages.
def _finalize(self): if self.status in ['running', 'halt']: if self.verbose > 0: print_('\nSampling finished normally.') self.status = 'ready' self.save_state() self.db._finalize()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_finalize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '33', '39']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'in'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '11', 'type': 'list', 'children': ['12', '13'], 'value': "['running', 'halt']"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'running'"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'halt'"}; {'id': '14', 'type': 'block', 'children': ['15', '27']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '21']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': '>'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'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': 'string', 'children': [], 'value': "'\\nSampling finished normally.'"}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'ready'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'save_state'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_finalize'}; {'id': '46', 'type': 'argument_list', 'children': []}
Reset the status and tell the database to finalize the traces.
def print_square(row_queue, t): occupied_rows = {y: row for _, y, row in row_queue} empty_row = ', '.join('...' for _ in range(t)) for y in range(t): print('|', end=' ') if y not in occupied_rows: print(empty_row, end=' ') else: row = dict(occupied_rows[y]) all_cols = ('%3d' % row[x] if x in row else '...' for x in range(t)) print(', '.join(all_cols), end=' ') print("|")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_square'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'row_queue'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '35']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'occupied_rows'}; {'id': '10', 'type': 'dictionary_comprehension', 'children': ['11', '14']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '14', 'type': 'for_in_clause', 'children': ['15', '19']}; {'id': '15', 'type': 'pattern_list', 'children': ['16', '17', '18']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'row_queue'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'empty_row'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "', '"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '27', 'type': 'generator_expression', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'...'"}; {'id': '29', 'type': 'for_in_clause', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '41']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '41', 'type': 'block', 'children': ['42', '50', '107']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'|'"}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '49', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '50', 'type': 'if_statement', 'children': ['51', '54', '63']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': 'not in'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'occupied_rows'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'empty_row'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '62', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '63', 'type': 'else_clause', 'children': ['64']}; {'id': '64', 'type': 'block', 'children': ['65', '74', '94']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'occupied_rows'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'all_cols'}; {'id': '77', 'type': 'generator_expression', 'children': ['78', '88']}; {'id': '78', 'type': 'conditional_expression', 'children': ['79', '84', '87'], 'value': 'if'}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '81'], 'value': '%'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'%3d'"}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': 'in'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'...'"}; {'id': '88', 'type': 'for_in_clause', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '104']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': "', '"}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'all_cols'}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '106', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'string', 'children': [], 'value': '"|"'}
Prints a row queue as its conceptual square array.
def move_to(x, y): for b in _button_state: if _button_state[b]: e = Quartz.CGEventCreateMouseEvent( None, _button_mapping[b][3], (x, y), _button_mapping[b][0]) break else: e = Quartz.CGEventCreateMouseEvent( None, Quartz.kCGEventMouseMoved, (x, y), Quartz.kCGMouseButtonLeft) Quartz.CGEventPost(Quartz.kCGHIDEventTap, e)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move_to'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '6', 'type': 'block', 'children': ['7', '59']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '10', '39']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_button_state'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_button_state'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '15', 'type': 'block', 'children': ['16', '38']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Quartz'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'CGEventCreateMouseEvent'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25', '30', '33']}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_button_mapping'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '30', 'type': 'tuple', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '33', 'type': 'subscript', 'children': ['34', '37']}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_button_mapping'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'break_statement', 'children': []}; {'id': '39', 'type': 'else_clause', 'children': ['40']}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Quartz'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'CGEventCreateMouseEvent'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50', '53', '56']}; {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'Quartz'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'kCGEventMouseMoved'}; {'id': '53', 'type': 'tuple', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'Quartz'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'kCGMouseButtonLeft'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'Quartz'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'CGEventPost'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Quartz'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'kCGHIDEventTap'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'e'}
Sets the mouse's location to the specified coordinates.
def check_presence_download(filename, backup_url): import os filename = str(filename) if not os.path.exists(filename): from .readwrite import download_progress dr = os.path.dirname(filename) try: os.makedirs(dr) except FileExistsError: pass from urllib.request import urlretrieve urlretrieve(backup_url, filename, reporthook=download_progress)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_presence_download'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'backup_url'}; {'id': '6', 'type': 'block', 'children': ['7', '10', '17']}; {'id': '7', 'type': 'import_statement', 'children': ['8']}; {'id': '8', 'type': 'dotted_name', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '27']}; {'id': '18', 'type': 'not_operator', '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': 'os'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '27', 'type': 'block', 'children': ['28', '35', '46', '59', '65']}; {'id': '28', 'type': 'import_from_statement', 'children': ['29', '33']}; {'id': '29', 'type': 'relative_import', 'children': ['30', '31']}; {'id': '30', 'type': 'import_prefix', 'children': []}; {'id': '31', 'type': 'dotted_name', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'readwrite'}; {'id': '33', 'type': 'dotted_name', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'download_progress'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'dr'}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '46', 'type': 'try_statement', 'children': ['47', '55']}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dr'}; {'id': '55', 'type': 'except_clause', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'FileExistsError'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'pass_statement', 'children': []}; {'id': '59', 'type': 'import_from_statement', 'children': ['60', '63']}; {'id': '60', 'type': 'dotted_name', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'urllib'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '63', 'type': 'dotted_name', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'urlretrieve'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'urlretrieve'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '70', '71']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'backup_url'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'reporthook'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'download_progress'}
Check if file is present otherwise download.
def build_FAILED(self, prgnam): self.template(78) print("| Some error on the package {0} [ {1}FAILED{2} ]".format( prgnam, self.meta.color["RED"], self.meta.color["ENDC"])) self.template(78) print("| See the log file in '{0}/var/log/slpkg/sbo/build_logs{1}' " "directory or read the README file".format( self.meta.color["CYAN"], self.meta.color["ENDC"])) self.template(78) print("")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_FAILED'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'prgnam'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '38', '45', '70', '77']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'integer', 'children': [], 'value': '78'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"| Some error on the package {0} [ {1}FAILED{2} ]"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '31']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'prgnam'}; {'id': '24', 'type': 'subscript', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"RED"'}; {'id': '31', 'type': 'subscript', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"ENDC"'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'integer', 'children': [], 'value': '78'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'concatenated_string', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"| See the log file in \'{0}/var/log/slpkg/sbo/build_logs{1}\' "'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"directory or read the README file"'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '63']}; {'id': '56', 'type': 'subscript', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"CYAN"'}; {'id': '63', 'type': 'subscript', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"ENDC"'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'integer', 'children': [], 'value': '78'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'string', 'children': [], 'value': '""'}
Print error message if build failed
def filter_data(df, filter_name, verbose=False): "Filter certain entries with given name." df = df[df.stop_name.apply( lambda cell: filter_name.encode('utf-8') in cell)] if verbose: msg = '- Filtered down to %d entries containing "%s".' print(msg % (len(df), filter_name)) return df
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filter_name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '12', '35', '54']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"Filter certain entries with given name."'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'df'}; {'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': 'df'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'stop_name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'apply'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'lambda', 'children': ['25', '27']}; {'id': '25', 'type': 'lambda_parameters', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '34'], 'value': 'in'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'filter_name'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '37', 'type': 'block', 'children': ['38', '42']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '41', 'type': 'string', 'children': [], 'value': '\'- Filtered down to %d entries containing "%s".\''}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '%'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '48', 'type': 'tuple', 'children': ['49', '53']}; {'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': 'df'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'filter_name'}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'df'}
Filter certain entries with given name.
def predict(self, inputs: np.ndarray) -> np.ndarray: return self.sess.run(self.out_var, {self.inp_var: inputs})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'predict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_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': 'sess'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'out_var'}; {'id': '27', 'type': 'dictionary', 'children': ['28']}; {'id': '28', 'type': 'pair', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'inp_var'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'inputs'}
Run on multiple inputs
def delLadder(name): ladders = getKnownLadders() try: ladder = ladders[name] os.remove(ladder.filename) del ladders[name] return ladder except KeyError: raise ValueError("given ladder name '%s' is not a known ladder definition"%(name))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delLadder'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ladders'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'getKnownLadders'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'try_statement', 'children': ['13', '35']}; {'id': '13', 'type': 'block', 'children': ['14', '20', '29', '33']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ladder'}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ladders'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ladder'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '29', 'type': 'delete_statement', 'children': ['30']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ladders'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ladder'}; {'id': '35', 'type': 'except_clause', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'raise_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '%'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"given ladder name \'%s\' is not a known ladder definition"'}; {'id': '44', 'type': '()', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'name'}
forget about a previously defined Ladder setting by deleting its disk file
def from_data(data): header, length = struct.unpack('4s<I', data[:8]) data = data[8:] return RiffDataChunk(header, data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6', '22', '30']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'unpack'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'4s<I'"}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '19', 'type': 'slice', 'children': ['20', '21']}; {'id': '20', 'type': 'colon', 'children': []}; {'id': '21', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '27', 'type': 'slice', 'children': ['28', '29']}; {'id': '28', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '29', 'type': 'colon', 'children': []}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'RiffDataChunk'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data'}
Create a chunk from data including header and length bytes.
def worker(data): creator = get_creator_by_name(data['creator']) shell = creator(data['entry'], ShellConfig(script=data['entry']['script'], title=data['entry']['title'] if 'title' in data['entry'] else '', model=data['model'], env=data['env'], item=data['item'], dry_run=data['dry_run'], debug=data['debug'], strict=data['strict'], variables=data['variables'], temporary_scripts_path=data['temporary_scripts_path'])) output = [] for line in shell.process(): output.append(line) Logger.get_logger(__name__ + '.worker').info(" | %s", line) return {'id': data['id'], 'success': shell.success, 'output': output}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'worker'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '88', '92', '122']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'creator'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'get_creator_by_name'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'creator'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'creator'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'entry'"}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ShellConfig'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '34', '48', '53', '58', '63', '68', '73', '78', '83']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '29', 'type': 'subscript', 'children': ['30', '33']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'entry'"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'script'"}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '36', 'type': 'conditional_expression', 'children': ['37', '42', '47'], 'value': 'if'}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'entry'"}; {'id': '41', 'type': 'string', 'children': [], 'value': "'title'"}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'in'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'title'"}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'entry'"}; {'id': '47', 'type': 'string', 'children': [], 'value': "''"}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'model'"}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'env'"}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'item'"}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'dry_run'}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'dry_run'"}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'debug'"}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'strict'}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'strict'"}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'variables'"}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'temporary_scripts_path'}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'temporary_scripts_path'"}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '91', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '92', 'type': 'for_statement', 'children': ['93', '94', '99']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'process'}; {'id': '98', 'type': 'argument_list', 'children': []}; {'id': '99', 'type': 'block', 'children': ['100', '107']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '119']}; {'id': '109', 'type': 'attribute', 'children': ['110', '118']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'Logger'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'get_logger'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'binary_operator', 'children': ['116', '117'], 'value': '+'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '117', 'type': 'string', 'children': [], 'value': "'.worker'"}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '121']}; {'id': '120', 'type': 'string', 'children': [], 'value': '" | %s"'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '122', 'type': 'return_statement', 'children': ['123']}; {'id': '123', 'type': 'dictionary', 'children': ['124', '129', '134']}; {'id': '124', 'type': 'pair', 'children': ['125', '126']}; {'id': '125', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '126', 'type': 'subscript', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '128', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '129', 'type': 'pair', 'children': ['130', '131']}; {'id': '130', 'type': 'string', 'children': [], 'value': "'success'"}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'shell'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '134', 'type': 'pair', 'children': ['135', '136']}; {'id': '135', 'type': 'string', 'children': [], 'value': "'output'"}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'output'}
Running on shell via multiprocessing.
def tmpfile(prefix, direc): return tempfile.mktemp(prefix=prefix, suffix='.pdb', dir=direc)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tmpfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'direc'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'tempfile'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'mktemp'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16', '19']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'.pdb'"}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'direc'}
Returns the path to a newly created temporary file.
def decrease_weight(self, proxy): new_weight = proxy.weight * self.dec_ratio if new_weight < self.weight_thr: self.remove_proxy(proxy) else: proxy.weight = new_weight
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'decrease_weight'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'new_weight'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '14'], 'value': '*'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'weight'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dec_ratio'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23', '31']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': '<'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'new_weight'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'weight_thr'}; {'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': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'remove_proxy'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '31', 'type': 'else_clause', 'children': ['32']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'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': 'proxy'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'weight'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'new_weight'}
Decreasing the weight of a proxy by multiplying dec_ratio
def randomArray(size, bound): if type(size) == type(1): size = (size,) temp = Numeric.array( ndim(*size) ) * (2.0 * bound) return temp - bound
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'randomArray'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'bound'}; {'id': '6', 'type': 'block', 'children': ['7', '23', '41']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '=='}; {'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': 'size'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '21', 'type': 'tuple', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '37'], 'value': '*'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Numeric'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'list_splat', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '37', 'type': '()', 'children': ['38']}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '*'}; {'id': '39', 'type': 'float', 'children': [], 'value': '2.0'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'bound'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '-'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'bound'}
Returns an array initialized to random values between -max and max.