code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def clean_new_password2(self):
password1 = self.cleaned_data.get('new_password1')
password2 = self.cleaned_data.get('new_password2')
try:
directory = APPLICATION.default_account_store_mapping.account_store
directory.password_policy.strength.validate_password(password2)
except ValueError as e:
raise forms.ValidationError(str(e))
if password1 and password2:
if password1 != password2:
raise forms.ValidationError("The two passwords didn't match.")
return password2
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_new_password2'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '28', '65', '82']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'password1'}; {'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': 'cleaned_data'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'new_password1'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'password2'}; {'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': 'cleaned_data'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'new_password2'"}; {'id': '28', 'type': 'try_statement', 'children': ['29', '49']}; {'id': '29', 'type': 'block', 'children': ['30', '38']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'APPLICATION'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'default_account_store_mapping'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'account_store'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '47']}; {'id': '40', 'type': 'attribute', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'password_policy'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'strength'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'validate_password'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'password2'}; {'id': '49', 'type': 'except_clause', 'children': ['50', '54']}; {'id': '50', 'type': 'as_pattern', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '52', 'type': 'as_pattern_target', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'raise_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'forms'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ValidationError'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '65', 'type': 'if_statement', 'children': ['66', '69']}; {'id': '66', 'type': 'boolean_operator', 'children': ['67', '68'], 'value': 'and'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'password1'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'password2'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'if_statement', 'children': ['71', '74']}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': '!='}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'password1'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'password2'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'raise_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'forms'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ValidationError'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'string', 'children': [], 'value': '"The two passwords didn\'t match."'}; {'id': '82', 'type': 'return_statement', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'password2'}
|
Check if passwords match and are valid.
|
def process_result_value(self, value, dialect):
if value is not None:
with BytesIO(value) as stream:
with GzipFile(fileobj=stream, mode="rb") as file_handle:
value = json.loads(file_handle.read().decode("utf-8"))
return value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_result_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '7', 'type': 'block', 'children': ['8', '58']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is not'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'with_statement', 'children': ['14', '23']}; {'id': '14', 'type': 'with_clause', 'children': ['15']}; {'id': '15', 'type': 'with_item', 'children': ['16']}; {'id': '16', 'type': 'as_pattern', 'children': ['17', '21']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'BytesIO'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'as_pattern_target', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'with_statement', 'children': ['25', '39']}; {'id': '25', 'type': 'with_clause', 'children': ['26']}; {'id': '26', 'type': 'with_item', 'children': ['27']}; {'id': '27', 'type': 'as_pattern', 'children': ['28', '37']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'GzipFile'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'fileobj'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"rb"'}; {'id': '37', 'type': 'as_pattern_target', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'file_handle'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '56']}; {'id': '49', 'type': 'attribute', 'children': ['50', '55']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'file_handle'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"utf-8"'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Convert a JSON encoded string to a dictionary structure.
|
def update_stale(self):
for etype, echannels in self.event_states.items():
for eprop in echannels:
if eprop[3] is not None:
sec_elap = ((datetime.datetime.now()-eprop[3])
.total_seconds())
if sec_elap > 5 and eprop[0] is True:
_LOGGING.debug('Updating stale event %s on CH(%s)',
etype, eprop[1])
attr = [False, eprop[1], eprop[2],
datetime.datetime.now()]
self.update_attributes(etype, eprop[1], attr)
self.publish_changes(etype, eprop[1])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_stale'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '17']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'etype'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'echannels'}; {'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': 'event_states'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'echannels'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '28']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': 'is not'}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29', '49']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sec_elap'}; {'id': '32', 'type': '()', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '48']}; {'id': '34', 'type': 'attribute', 'children': ['35', '47']}; {'id': '35', 'type': '()', 'children': ['36']}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '44'], 'value': '-'}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'total_seconds'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'if_statement', 'children': ['50', '59']}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '54'], 'value': 'and'}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': '>'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'sec_elap'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '58'], 'value': 'is'}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'True', 'children': []}; {'id': '59', 'type': 'block', 'children': ['60', '71', '89', '100']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_LOGGING'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'Updating stale event %s on CH(%s)'"}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'etype'}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '74', 'type': 'list', 'children': ['75', '76', '79', '82'], 'value': '[False, eprop[1], eprop[2],\n datetime.datetime.now()]'}; {'id': '75', 'type': 'False', 'children': []}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '82', 'type': 'call', 'children': ['83', '88']}; {'id': '83', 'type': 'attribute', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '88', 'type': 'argument_list', 'children': []}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'update_attributes'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96', '99']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'etype'}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'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': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'publish_changes'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'etype'}; {'id': '107', 'type': 'subscript', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'eprop'}; {'id': '109', 'type': 'integer', 'children': [], 'value': '1'}
|
Update stale active statuses
|
def on_backward_end(self, **kwargs:Any)->None:
"Convert the gradients back to FP32 and divide them by the scale."
if self.dynamic and grad_overflow(self.model_params) and self.loss_scale > 1:
self.loss_scale /= 2
self.noskip = 0
else:
model_g2master_g(self.model_params, self.master_params, self.flat_master)
for group in self.master_params:
for param in group:
if param.grad is not None: param.grad.div_(self.loss_scale)
if self.clip is not None:
for group in self.master_params: nn.utils.clip_grad_norm_(group, self.clip)
if not self.dynamic: return
self.noskip += 1
if self.noskip >= self.max_noskip and self.loss_scale < self.max_scale:
self.loss_scale *= 2
self.noskip = 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_backward_end'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '8']}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Any'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '15']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"Convert the gradients back to FP32 and divide them by the scale."'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '32', '45']}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '27'], 'value': 'and'}; {'id': '17', 'type': 'boolean_operator', 'children': ['18', '21'], 'value': 'and'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dynamic'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'grad_overflow'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'model_params'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '31'], 'value': '>'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'loss_scale'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'block', 'children': ['33', '39']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'augmented_assignment', 'children': ['35', '38'], 'value': '/='}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'loss_scale'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'noskip'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47', '60', '88', '113', '120', '126']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'model_g2master_g'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '54', '57']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'model_params'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'master_params'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'flat_master'}; {'id': '60', 'type': 'for_statement', 'children': ['61', '62', '65']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'master_params'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'for_statement', 'children': ['67', '68', '69']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'if_statement', 'children': ['71', '76']}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '75'], 'value': 'is not'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'grad'}; {'id': '75', 'type': 'None', 'children': []}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '84']}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'grad'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'div_'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'loss_scale'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '94']}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '93'], 'value': 'is not'}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '93', 'type': 'None', 'children': []}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'for_statement', 'children': ['96', '97', '100']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'master_params'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '108']}; {'id': '103', 'type': 'attribute', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'nn'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'clip_grad_norm_'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '113', 'type': 'if_statement', 'children': ['114', '118']}; {'id': '114', 'type': 'not_operator', 'children': ['115']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'dynamic'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'return_statement', 'children': []}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'augmented_assignment', 'children': ['122', '125'], 'value': '+='}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'noskip'}; {'id': '125', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '126', 'type': 'if_statement', 'children': ['127', '142']}; {'id': '127', 'type': 'boolean_operator', 'children': ['128', '135'], 'value': 'and'}; {'id': '128', 'type': 'comparison_operator', 'children': ['129', '132'], 'value': '>='}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'noskip'}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'max_noskip'}; {'id': '135', 'type': 'comparison_operator', 'children': ['136', '139'], 'value': '<'}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'loss_scale'}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'max_scale'}; {'id': '142', 'type': 'block', 'children': ['143', '149']}; {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'augmented_assignment', 'children': ['145', '148'], 'value': '*='}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'loss_scale'}; {'id': '148', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'noskip'}; {'id': '154', 'type': 'integer', 'children': [], 'value': '0'}
|
Convert the gradients back to FP32 and divide them by the scale.
|
def request(self, method, path, params=None, headers=None, body=None):
if not headers:
headers = {}
if not params:
params = {}
headers["Accept"] = "application/json"
headers["Accept-Version"] = "^1.15.0"
if self.auth_token:
headers["Authorization"] = "Bearer {0}".format(self.auth_token)
path = self.url + path
params = self.flatten_params(params)
response = requests.request(method, path, params=params, headers=headers, json=body)
result = response.text
try:
result = response.json()
except Exception:
pass
if response.status_code >= 400:
raise LosantError(response.status_code, result)
return result
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '25', '33', '39', '45', '63', '71', '80', '99', '105', '119', '134']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '20']}; {'id': '18', 'type': 'not_operator', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '24', 'type': 'dictionary', 'children': []}; {'id': '25', 'type': 'if_statement', 'children': ['26', '28']}; {'id': '26', 'type': 'not_operator', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '32', 'type': 'dictionary', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"Accept"'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"application/json"'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"Accept-Version"'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"^1.15.0"'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'auth_token'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '54', 'type': 'string', 'children': [], 'value': '"Authorization"'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"Bearer {0}"'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'auth_token'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '70'], 'value': '+'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'flatten_params'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89', '90', '93', '96']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '96', 'type': 'keyword_argument', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '105', 'type': 'try_statement', 'children': ['106', '115']}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '114', 'type': 'argument_list', 'children': []}; {'id': '115', 'type': 'except_clause', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '117', 'type': 'block', 'children': ['118']}; {'id': '118', 'type': 'pass_statement', 'children': []}; {'id': '119', 'type': 'if_statement', 'children': ['120', '125']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '124'], 'value': '>='}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '124', 'type': 'integer', 'children': [], 'value': '400'}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'raise_statement', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'LosantError'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '134', 'type': 'return_statement', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'result'}
|
Base method for making a Losant API request
|
def _create_credentials(self, n):
if not n:
return n
elif isinstance(n, SecurityCreds):
return n
elif isinstance(n, dict):
return SecurityCreds(**n)
else:
raise TypeError("%s is not a valid security configuration"
% repr(n))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_credentials'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '10', '13', '22', '35']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '13', 'type': 'elif_clause', 'children': ['14', '19']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'SecurityCreds'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '22', 'type': 'elif_clause', 'children': ['23', '28']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'SecurityCreds'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'dictionary_splat', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'raise_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '%'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"%s is not a valid security configuration"'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'n'}
|
Create security credentials, if necessary.
|
def restore_watched(plex, opts):
with open(opts.filepath, 'r') as handle:
source = json.load(handle)
differences = defaultdict(lambda: dict())
for section in _iter_sections(plex, opts):
print('Finding differences in %s..' % section.title)
skey = section.title.lower()
for item in _iter_items(section):
ikey = _item_key(item)
sval = source.get(skey,{}).get(ikey)
if sval is None:
raise SystemExit('%s not found' % ikey)
if (sval is not None and item.isWatched != sval) and (not opts.watchedonly or sval):
differences[skey][ikey] = {'isWatched':sval, 'item':item}
print('Applying %s differences to destination' % len(differences))
import pprint; pprint.pprint(differences)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'restore_watched'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'plex'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '6', 'type': 'block', 'children': ['7', '30', '40', '142', '152', '155']}; {'id': '7', 'type': 'with_statement', 'children': ['8', '20']}; {'id': '8', 'type': 'with_clause', 'children': ['9']}; {'id': '9', 'type': 'with_item', 'children': ['10']}; {'id': '10', 'type': 'as_pattern', 'children': ['11', '18']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'filepath'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '18', 'type': 'as_pattern_target', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'differences'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'defaultdict'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'lambda', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'for_statement', 'children': ['41', '42', '47']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_iter_sections'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'plex'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '47', 'type': 'block', 'children': ['48', '57', '67']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '%'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'Finding differences in %s..'"}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'skey'}; {'id': '60', 'type': 'call', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'for_statement', 'children': ['68', '69', '73']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_iter_items'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '73', 'type': 'block', 'children': ['74', '81', '96', '108']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ikey'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_item_key'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'sval'}; {'id': '84', 'type': 'call', 'children': ['85', '94']}; {'id': '85', 'type': 'attribute', 'children': ['86', '93']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'skey'}; {'id': '92', 'type': 'dictionary', 'children': []}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ikey'}; {'id': '96', 'type': 'if_statement', 'children': ['97', '100']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': 'is'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'sval'}; {'id': '99', 'type': 'None', 'children': []}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'raise_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'SystemExit'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'binary_operator', 'children': ['106', '107'], 'value': '%'}; {'id': '106', 'type': 'string', 'children': [], 'value': "'%s not found'"}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'ikey'}; {'id': '108', 'type': 'if_statement', 'children': ['109', '127']}; {'id': '109', 'type': 'boolean_operator', 'children': ['110', '120'], 'value': 'and'}; {'id': '110', 'type': '()', 'children': ['111']}; {'id': '111', 'type': 'boolean_operator', 'children': ['112', '115'], 'value': 'and'}; {'id': '112', 'type': 'comparison_operator', 'children': ['113', '114'], 'value': 'is not'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'sval'}; {'id': '114', 'type': 'None', 'children': []}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '119'], 'value': '!='}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'isWatched'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'sval'}; {'id': '120', 'type': '()', 'children': ['121']}; {'id': '121', 'type': 'boolean_operator', 'children': ['122', '126'], 'value': 'or'}; {'id': '122', 'type': 'not_operator', 'children': ['123']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'watchedonly'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'sval'}; {'id': '127', 'type': 'block', 'children': ['128']}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'assignment', 'children': ['130', '135']}; {'id': '130', 'type': 'subscript', 'children': ['131', '134']}; {'id': '131', 'type': 'subscript', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'differences'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'skey'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'ikey'}; {'id': '135', 'type': 'dictionary', 'children': ['136', '139']}; {'id': '136', 'type': 'pair', 'children': ['137', '138']}; {'id': '137', 'type': 'string', 'children': [], 'value': "'isWatched'"}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'sval'}; {'id': '139', 'type': 'pair', 'children': ['140', '141']}; {'id': '140', 'type': 'string', 'children': [], 'value': "'item'"}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}; {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'binary_operator', 'children': ['147', '148'], 'value': '%'}; {'id': '147', 'type': 'string', 'children': [], 'value': "'Applying %s differences to destination'"}; {'id': '148', 'type': 'call', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'differences'}; {'id': '152', 'type': 'import_statement', 'children': ['153']}; {'id': '153', 'type': 'dotted_name', 'children': ['154']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'pprint'}; {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'call', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'pprint'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'pprint'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'differences'}
|
Restore watched status from the specified filepath.
|
def find_best_periods(self, n_periods=5, return_scores=False):
return self.optimizer.find_best_periods(self, n_periods,
return_scores=return_scores)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_best_periods'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'n_periods'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'return_scores'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'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': 'optimizer'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'find_best_periods'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'n_periods'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'return_scores'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'return_scores'}
|
Find the top several best periods for the model
|
def parse_in_line(txt: str, units: Units) -> typing.Dict[str, str]:
retwx = {}
wxdata = txt.split(' ')
wxdata, _, retwx['wind_shear'] = core.sanitize_report_list(wxdata)
wxdata, retwx['type'], retwx['start_time'], retwx['end_time'] = core.get_type_and_times(wxdata)
wxdata, retwx['wind_direction'], retwx['wind_speed'], \
retwx['wind_gust'], _ = core.get_wind(wxdata, units)
if 'CAVOK' in wxdata:
retwx['visibility'] = core.make_number('CAVOK')
retwx['clouds'] = []
wxdata.pop(wxdata.index('CAVOK'))
else:
wxdata, retwx['visibility'] = core.get_visibility(wxdata, units)
wxdata, retwx['clouds'] = core.get_clouds(wxdata)
retwx['other'], retwx['altimeter'], retwx['icing'], retwx['turbulance'] \
= core.get_taf_alt_ice_turb(wxdata)
return retwx
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_in_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'txt'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Units'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'subscript', 'children': ['14', '17', '18']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'typing'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Dict'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '19', 'type': 'block', 'children': ['20', '24', '33', '47', '66', '88', '151', '173']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '23', 'type': 'dictionary', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'txt'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '41']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'wind_shear'"}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'sanitize_report_list'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '60']}; {'id': '49', 'type': 'pattern_list', 'children': ['50', '51', '54', '57']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'start_time'"}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'end_time'"}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'get_type_and_times'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '81']}; {'id': '68', 'type': 'pattern_list', 'children': ['69', '70', '73', '76', '77', '80']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'wind_direction'"}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'wind_speed'"}; {'id': '76', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'wind_gust'"}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'get_wind'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '92', '122']}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '91'], 'value': 'in'}; {'id': '90', 'type': 'string', 'children': [], 'value': "'CAVOK'"}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '92', 'type': 'block', 'children': ['93', '104', '110']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '98']}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '97', 'type': 'string', 'children': [], 'value': "'visibility'"}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'make_number'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'string', 'children': [], 'value': "'CAVOK'"}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '109']}; {'id': '106', 'type': 'subscript', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '108', 'type': 'string', 'children': [], 'value': "'clouds'"}; {'id': '109', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'string', 'children': [], 'value': "'CAVOK'"}; {'id': '122', 'type': 'else_clause', 'children': ['123']}; {'id': '123', 'type': 'block', 'children': ['124', '138']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '131']}; {'id': '126', 'type': 'pattern_list', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '130', 'type': 'string', 'children': [], 'value': "'visibility'"}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'get_visibility'}; {'id': '135', 'type': 'argument_list', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '145']}; {'id': '140', 'type': 'pattern_list', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '142', 'type': 'subscript', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '144', 'type': 'string', 'children': [], 'value': "'clouds'"}; {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'get_clouds'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '166', '167']}; {'id': '153', 'type': 'pattern_list', 'children': ['154', '157', '160', '163']}; {'id': '154', 'type': 'subscript', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '156', 'type': 'string', 'children': [], 'value': "'other'"}; {'id': '157', 'type': 'subscript', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '159', 'type': 'string', 'children': [], 'value': "'altimeter'"}; {'id': '160', 'type': 'subscript', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '162', 'type': 'string', 'children': [], 'value': "'icing'"}; {'id': '163', 'type': 'subscript', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'retwx'}; {'id': '165', 'type': 'string', 'children': [], 'value': "'turbulance'"}; {'id': '166', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'get_taf_alt_ice_turb'}; {'id': '171', 'type': 'argument_list', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'wxdata'}; {'id': '173', 'type': 'return_statement', 'children': ['174']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'retwx'}
|
Parser for the International TAF forcast varient
|
def _get_masses(fitnesses):
best_fitness = max(fitnesses)
worst_fitness = min(fitnesses)
fitness_range = best_fitness - worst_fitness
raw_masses = []
for fitness in fitnesses:
raw_masses.append((fitness - worst_fitness) / (fitness_range + EPSILON)
+ EPSILON)
total_mass = sum(raw_masses)
masses = []
for mass in raw_masses:
masses.append(mass / total_mass)
return masses
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_masses'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fitnesses'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '20', '26', '30', '51', '58', '62', '75']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'best_fitness'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'fitnesses'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'worst_fitness'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fitnesses'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fitness_range'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '-'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'best_fitness'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'worst_fitness'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'raw_masses'}; {'id': '29', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '30', 'type': 'for_statement', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fitness'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'fitnesses'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'raw_masses'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '50'], 'value': '+'}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '46'], 'value': '/'}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '-'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fitness'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'worst_fitness'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '49'], 'value': '+'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'fitness_range'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'EPSILON'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'EPSILON'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'total_mass'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'raw_masses'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'masses'}; {'id': '61', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '62', 'type': 'for_statement', 'children': ['63', '64', '65']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'raw_masses'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'masses'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '74'], 'value': '/'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'mass'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'total_mass'}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'masses'}
|
Convert fitnesses into masses, as given by GSA algorithm.
|
def attach_core_filters(cls):
opts = cls._meta
base_filters = cls.base_filters.copy()
cls.base_filters.clear()
for name, filter_ in six.iteritems(base_filters):
if isinstance(filter_, AutoFilters):
field = filterset.get_model_field(opts.model, filter_.name)
filter_exclusion = filter_.extra.pop('drop', [])
for lookup_expr in utils.lookups_for_field(field):
if lookup_expr not in filter_exclusion:
new_filter = cls.filter_for_field(field, filter_.name, lookup_expr)
if lookup_expr != 'exact':
filter_name = LOOKUP_SEP.join([name, lookup_expr])
else:
filter_name = name
cls.base_filters[filter_name] = new_filter
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'attach_core_filters'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '22', '30']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'base_filters'}; {'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': 'cls'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'base_filters'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'base_filters'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'for_statement', 'children': ['31', '34', '40']}; {'id': '31', 'type': 'pattern_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'filter_'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'base_filters'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '47']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'filter_'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'AutoFilters'}; {'id': '47', 'type': 'block', 'children': ['48', '62', '74']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'filterset'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get_model_field'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'filter_'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'filter_exclusion'}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'filter_'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'drop'"}; {'id': '73', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '74', 'type': 'for_statement', 'children': ['75', '76', '82']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'lookup_expr'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'lookups_for_field'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'if_statement', 'children': ['84', '87']}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': 'not in'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'lookup_expr'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'filter_exclusion'}; {'id': '87', 'type': 'block', 'children': ['88', '101', '123']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'new_filter'}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'filter_for_field'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '97', '100']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'filter_'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'lookup_expr'}; {'id': '101', 'type': 'if_statement', 'children': ['102', '105', '117']}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': '!='}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'lookup_expr'}; {'id': '104', 'type': 'string', 'children': [], 'value': "'exact'"}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'filter_name'}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'LOOKUP_SEP'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'list', 'children': ['115', '116'], 'value': '[name, lookup_expr]'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'lookup_expr'}; {'id': '117', 'type': 'else_clause', 'children': ['118']}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'filter_name'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '130']}; {'id': '125', 'type': 'subscript', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'base_filters'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'filter_name'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'new_filter'}
|
Attach core filters to filterset
|
def _irc_lower(self, in_string):
conv_string = self._translate(in_string)
if self._lower_trans is not None:
conv_string = conv_string.translate(self._lower_trans)
return str.lower(conv_string)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_irc_lower'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'in_string'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '34']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'conv_string'}; {'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': '_translate'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'in_string'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '22']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '21'], 'value': 'is not'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_lower_trans'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'conv_string'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'conv_string'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'translate'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_lower_trans'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'conv_string'}
|
Convert us to our lower-case equivalent, given our std.
|
def make_keys_safe(dct):
result = {}
for key, val in dct.items():
key = key.replace('-', '_')
if key in keyword.kwlist:
key = key + '_'
result[key] = val
return result
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_keys_safe'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dct'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '49']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '14', '19']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dct'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20', '30', '43']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '29', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '30', 'type': 'if_statement', 'children': ['31', '36']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': 'in'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'keyword'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'kwlist'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '+'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'result'}
|
Modify the keys in |dct| to be valid attribute names.
|
def check_section_oversized(self):
total_image_size = self.pefile_handle.OPTIONAL_HEADER.SizeOfImage
for section in self.pefile_handle.sections:
if section.PointerToRawData + section.SizeOfRawData > total_image_size:
return {'description': 'Oversized section, storing addition data within the PE',
'severity': 3, 'category': 'MALFORMED', 'attributes': section.Name}
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_section_oversized'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '51']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'total_image_size'}; {'id': '9', 'type': 'attribute', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pefile_handle'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'OPTIONAL_HEADER'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'SizeOfImage'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '23']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'section'}; {'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': 'pefile_handle'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sections'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '34']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '33'], 'value': '>'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '30'], 'value': '+'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'PointerToRawData'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'SizeOfRawData'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'total_image_size'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'dictionary', 'children': ['37', '40', '43', '46']}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'description'"}; {'id': '39', 'type': 'string', 'children': [], 'value': "'Oversized section, storing addition data within the PE'"}; {'id': '40', 'type': 'pair', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'severity'"}; {'id': '42', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'category'"}; {'id': '45', 'type': 'string', 'children': [], 'value': "'MALFORMED'"}; {'id': '46', 'type': 'pair', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'attributes'"}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'Name'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'None', 'children': []}
|
Checking if any of the sections go past the total size of the image
|
def list_lbaas_healthmonitors(self, retrieve_all=True, **_params):
return self.list('healthmonitors', self.lbaas_healthmonitors_path,
retrieve_all, **_params)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_lbaas_healthmonitors'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'retrieve_all'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_params'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '21', '22']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'healthmonitors'"}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'lbaas_healthmonitors_path'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'retrieve_all'}; {'id': '22', 'type': 'dictionary_splat', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_params'}
|
Fetches a list of all lbaas_healthmonitors for a project.
|
def write(self, message, autoerase=True):
super(Animation, self).write(message)
self.last_message = message
if autoerase:
time.sleep(self.interval)
self.erase(message)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'autoerase'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '21', '27']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Animation'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'last_message'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'autoerase'}; {'id': '29', 'type': 'block', 'children': ['30', '39']}; {'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': 'time'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'erase'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'message'}
|
Send something for stdout and erased after delay
|
def format(item, **params):
encoding = params.get('charset', 'UTF-8')
return json.dumps(item, encoding=encoding)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'params'}; {'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': 'encoding'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'charset'"}; {'id': '17', 'type': 'string', 'children': [], 'value': "'UTF-8'"}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'encoding'}
|
Truns a python object into a JSON structure.
|
def in_subnet(cidr, addrs=None):
for address in addrs:
if ip_in_subnet(address, cidr):
return True
return False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'in_subnet'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cidr'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'addrs'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '22']}; {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '12']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'addrs'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '19']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ip_in_subnet'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cidr'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'True', 'children': []}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'False', 'children': []}
|
Returns True if host is within specified subnet, otherwise False
|
def prepare(self):
self.target = self.fn
self.targetheader = reader.get_tsv_header(self.target)
self.decoyheader = reader.get_tsv_header(self.decoyfn)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prepare'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '27']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'targetheader'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'get_tsv_header'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'target'}; {'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': 'decoyheader'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'reader'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'get_tsv_header'}; {'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': 'decoyfn'}
|
No percolator XML for protein tables
|
def encode_inputs(self):
litmap = dict()
nvars = 0
for i, v in enumerate(self.inputs, start=1):
litmap[v] = i
litmap[~v] = -i
litmap[i] = v
litmap[-i] = ~v
nvars += 1
return litmap, nvars
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode_inputs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '16', '62']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'litmap'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'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': 'nvars'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '20', '29']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '29', 'type': 'block', 'children': ['30', '36', '44', '50', '58']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'litmap'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '42']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'litmap'}; {'id': '40', 'type': 'unary_operator', 'children': ['41'], 'value': '~'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '42', 'type': 'unary_operator', 'children': ['43'], 'value': '-'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'litmap'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '56']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'litmap'}; {'id': '54', 'type': 'unary_operator', 'children': ['55'], 'value': '-'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '56', 'type': 'unary_operator', 'children': ['57'], 'value': '~'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'augmented_assignment', 'children': ['60', '61'], 'value': '+='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'nvars'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'expression_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'litmap'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'nvars'}
|
Return a compact encoding for input variables.
|
def reset(self):
if not self.leds:
return
self.animate_stop()
for group in self.led_groups:
self.set_color(group, LED_DEFAULT_COLOR)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '19']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'leds'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', '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': 'animate_stop'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '24']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'led_groups'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'set_color'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'LED_DEFAULT_COLOR'}
|
Put all LEDs back to their default color
|
def _get_seqprop_to_seqprop_alignment(self, seqprop1, seqprop2):
if isinstance(seqprop1, str):
seqprop1_id = seqprop1
else:
seqprop1_id = seqprop1.id
if isinstance(seqprop2, str):
seqprop2_id = seqprop2
else:
seqprop2_id = seqprop2.id
aln_id = '{}_{}'.format(seqprop1_id, seqprop2_id)
if self.sequence_alignments.has_id(aln_id):
alignment = self.sequence_alignments.get_by_id(aln_id)
return alignment
else:
raise ValueError('{}: sequence alignment not found, please run the alignment first'.format(aln_id))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_seqprop_to_seqprop_alignment'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'seqprop1'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'seqprop2'}; {'id': '7', 'type': 'block', 'children': ['8', '27', '46', '56']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14', '19']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'seqprop1'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'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': 'seqprop1_id'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'seqprop1'}; {'id': '19', 'type': 'else_clause', 'children': ['20']}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'seqprop1_id'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'seqprop1'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '33', '38']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'seqprop2'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'str'}; {'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': 'seqprop2_id'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'seqprop2'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'seqprop2_id'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'seqprop2'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'aln_id'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'{}_{}'"}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'seqprop1_id'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'seqprop2_id'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '65', '79']}; {'id': '57', 'type': 'call', 'children': ['58', '63']}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'sequence_alignments'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'has_id'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'aln_id'}; {'id': '65', 'type': 'block', 'children': ['66', '77']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'alignment'}; {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sequence_alignments'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_by_id'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'aln_id'}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'alignment'}; {'id': '79', 'type': 'else_clause', 'children': ['80']}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'raise_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'string', 'children': [], 'value': "'{}: sequence alignment not found, please run the alignment first'"}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'aln_id'}
|
Return the alignment stored in self.sequence_alignments given a seqprop + another seqprop
|
def search(table: LdapObjectClass, query: Optional[Q] = None,
database: Optional[Database] = None, base_dn: Optional[str] = None) -> Iterator[LdapObject]:
fields = table.get_fields()
db_fields = {
name: field
for name, field in fields.items()
if field.db_field
}
database = get_database(database)
connection = database.connection
search_options = table.get_search_options(database)
iterator = tldap.query.search(
connection=connection,
query=query,
fields=db_fields,
base_dn=base_dn or search_options.base_dn,
object_classes=search_options.object_class,
pk=search_options.pk_field,
)
for dn, data in iterator:
python_data = _db_to_python(data, table, dn)
python_data = table.on_load(python_data, database)
yield python_data
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '35', '41']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '17', '26']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'LdapObjectClass'}; {'id': '8', 'type': 'typed_default_parameter', 'children': ['9', '10', '16']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'generic_type', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '13', 'type': 'type_parameter', 'children': ['14']}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'typed_default_parameter', 'children': ['18', '19', '25']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '19', 'type': 'type', 'children': ['20']}; {'id': '20', 'type': 'generic_type', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '22', 'type': 'type_parameter', 'children': ['23']}; {'id': '23', 'type': 'type', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Database'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'typed_default_parameter', 'children': ['27', '28', '34']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'base_dn'}; {'id': '28', 'type': 'type', 'children': ['29']}; {'id': '29', 'type': 'generic_type', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '31', 'type': 'type_parameter', 'children': ['32']}; {'id': '32', 'type': 'type', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'type', 'children': ['36']}; {'id': '36', 'type': 'generic_type', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Iterator'}; {'id': '38', 'type': 'type_parameter', 'children': ['39']}; {'id': '39', 'type': 'type', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'LdapObject'}; {'id': '41', 'type': 'block', 'children': ['42', '50', '70', '77', '83', '92', '128']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'get_fields'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'db_fields'}; {'id': '53', 'type': 'dictionary_comprehension', 'children': ['54', '57', '66']}; {'id': '54', 'type': 'pair', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '57', 'type': 'for_in_clause', 'children': ['58', '61']}; {'id': '58', 'type': 'pattern_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '65', 'type': 'argument_list', 'children': []}; {'id': '66', 'type': 'if_clause', 'children': ['67']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'db_field'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_database'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'search_options'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'get_search_options'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'iterator'}; {'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': 'tldap'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '105', '108', '111', '118', '123']}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'db_fields'}; {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'base_dn'}; {'id': '113', 'type': 'boolean_operator', 'children': ['114', '115'], 'value': 'or'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'base_dn'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'search_options'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'base_dn'}; {'id': '118', 'type': 'keyword_argument', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'object_classes'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'search_options'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'object_class'}; {'id': '123', 'type': 'keyword_argument', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'search_options'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'pk_field'}; {'id': '128', 'type': 'for_statement', 'children': ['129', '132', '133']}; {'id': '129', 'type': 'pattern_list', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'dn'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'iterator'}; {'id': '133', 'type': 'block', 'children': ['134', '143', '153']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'python_data'}; {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': '_db_to_python'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141', '142']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'dn'}; {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'assignment', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'python_data'}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'on_load'}; {'id': '150', 'type': 'argument_list', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'python_data'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'yield', 'children': ['155']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'python_data'}
|
Search for a object of given type in the database.
|
def addstr(self, h, w, text, attrs=0):
self.update_window_size()
if h > self.height or w > self.width:
return
try:
self.window.addstr(h, w, text, attrs)
except Exception as e:
pass
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addstr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '11', 'type': 'block', 'children': ['12', '18', '32']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'update_window_size'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'if_statement', 'children': ['19', '30']}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '25'], 'value': 'or'}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': '>'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': '>'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': []}; {'id': '32', 'type': 'try_statement', 'children': ['33', '46']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'window'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'addstr'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43', '44', '45']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '46', 'type': 'except_clause', 'children': ['47', '51']}; {'id': '47', 'type': 'as_pattern', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '49', 'type': 'as_pattern_target', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'pass_statement', 'children': []}
|
A safe addstr wrapper
|
def _rescan(self, skip_to_end = True):
paths = []
for single_glob in self._globspec:
paths.extend(glob.glob(single_glob))
for path in self._tailedfiles.keys():
if path not in paths:
self._tailedfiles[path]._close()
del self._tailedfiles[path]
for path in paths:
try:
if self._tailedfiles[path].hasBeenRotated():
if not self._tailedfiles[path].reopen():
del self._tailedfiles[path]
except KeyError:
self._tailedfiles[path] = TailedFile(path, skip_to_end = skip_to_end, offset = self._offsets.get(path, None))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_rescan'}; {'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': 'skip_to_end'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '13', '31', '62']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '12', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'single_glob'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_globspec'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'single_glob'}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '40']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_tailedfiles'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'if_statement', 'children': ['42', '45']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'not in'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '45', 'type': 'block', 'children': ['46', '56']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '55']}; {'id': '48', 'type': 'attribute', 'children': ['49', '54']}; {'id': '49', 'type': 'subscript', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_tailedfiles'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_close'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'delete_statement', 'children': ['57']}; {'id': '57', 'type': 'subscript', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_tailedfiles'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '62', 'type': 'for_statement', 'children': ['63', '64', '65']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'try_statement', 'children': ['67', '97']}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'if_statement', 'children': ['69', '78']}; {'id': '69', 'type': 'call', 'children': ['70', '77']}; {'id': '70', 'type': 'attribute', 'children': ['71', '76']}; {'id': '71', 'type': 'subscript', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_tailedfiles'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'hasBeenRotated'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'if_statement', 'children': ['80', '90']}; {'id': '80', 'type': 'not_operator', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '89']}; {'id': '82', 'type': 'attribute', 'children': ['83', '88']}; {'id': '83', 'type': 'subscript', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_tailedfiles'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'reopen'}; {'id': '89', 'type': 'argument_list', 'children': []}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'delete_statement', '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': '_tailedfiles'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '97', 'type': 'except_clause', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '107']}; {'id': '102', 'type': 'subscript', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': '_tailedfiles'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'TailedFile'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111', '114']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'skip_to_end'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'skip_to_end'}; {'id': '114', 'type': 'keyword_argument', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '116', 'type': 'call', 'children': ['117', '122']}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': '_offsets'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '124', 'type': 'None', 'children': []}
|
Check for new files, deleted files, and rotated files.
|
def _options_dir(name):
_check_portname(name)
_root = '/var/db/ports'
new_dir = os.path.join(_root, name.replace('/', '_'))
old_dir = os.path.join(_root, name.split('/')[-1])
if os.path.isdir(old_dir):
return old_dir
return new_dir
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_options_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '15', '33', '53', '65']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_check_portname'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_root'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'/var/db/ports'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'new_dir'}; {'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': 'join'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_root'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '32', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'old_dir'}; {'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': 'os'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_root'}; {'id': '44', 'type': 'subscript', 'children': ['45', '51']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '51', 'type': 'unary_operator', 'children': ['52'], 'value': '-'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '62']}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'old_dir'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'old_dir'}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'new_dir'}
|
Retrieve the path to the dir containing OPTIONS file for a given port
|
def pretty_date(the_datetime):
diff = datetime.utcnow() - the_datetime
if diff.days > 7 or diff.days < 0:
return the_datetime.strftime('%A %B %d, %Y')
elif diff.days == 1:
return '1 day ago'
elif diff.days > 1:
return '{0} days ago'.format(diff.days)
elif diff.seconds <= 1:
return 'just now'
elif diff.seconds < 60:
return '{0} seconds ago'.format(diff.seconds)
elif diff.seconds < 120:
return '1 minute ago'
elif diff.seconds < 3600:
return '{0} minutes ago'.format(int(round(diff.seconds / 60)))
elif diff.seconds < 7200:
return '1 hour ago'
else:
return '{0} hours ago'.format(int(round(diff.seconds / 3600)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pretty_date'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'the_datetime'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '15'], 'value': '-'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'utcnow'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'the_datetime'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '28', '36', '45', '61', '70', '86', '95', '119', '128']}; {'id': '17', 'type': 'boolean_operator', 'children': ['18', '23'], 'value': 'or'}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': '>'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': '<'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'the_datetime'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'%A %B %d, %Y'"}; {'id': '36', 'type': 'elif_clause', 'children': ['37', '42']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '41'], 'value': '=='}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'1 day ago'"}; {'id': '45', 'type': 'elif_clause', 'children': ['46', '51']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '50'], 'value': '>'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'{0} days ago'"}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '61', 'type': 'elif_clause', 'children': ['62', '67']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '66'], 'value': '<='}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'string', 'children': [], 'value': "'just now'"}; {'id': '70', 'type': 'elif_clause', 'children': ['71', '76']}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '75'], 'value': '<'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'string', 'children': [], 'value': "'{0} seconds ago'"}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '86', 'type': 'elif_clause', 'children': ['87', '92']}; {'id': '87', 'type': 'comparison_operator', 'children': ['88', '91'], 'value': '<'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '120'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'string', 'children': [], 'value': "'1 minute ago'"}; {'id': '95', 'type': 'elif_clause', 'children': ['96', '101']}; {'id': '96', 'type': 'comparison_operator', 'children': ['97', '100'], 'value': '<'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '100', 'type': 'integer', 'children': [], 'value': '3600'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'string', 'children': [], 'value': "'{0} minutes ago'"}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'binary_operator', 'children': ['115', '118'], 'value': '/'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '118', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '119', 'type': 'elif_clause', 'children': ['120', '125']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '124'], 'value': '<'}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '124', 'type': 'integer', 'children': [], 'value': '7200'}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'return_statement', 'children': ['127']}; {'id': '127', 'type': 'string', 'children': [], 'value': "'1 hour ago'"}; {'id': '128', 'type': 'else_clause', 'children': ['129']}; {'id': '129', 'type': 'block', 'children': ['130']}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'string', 'children': [], 'value': "'{0} hours ago'"}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'call', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'binary_operator', 'children': ['143', '146'], 'value': '/'}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '146', 'type': 'integer', 'children': [], 'value': '3600'}
|
Attempt to return a human-readable time delta string.
|
def _with_rotation(self, w, h):
res_w = abs(w * math.cos(self.rotation) + h * math.sin(self.rotation))
res_h = abs(h * math.cos(self.rotation) + w * math.sin(self.rotation))
return res_w, res_h
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_with_rotation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '7', 'type': 'block', 'children': ['8', '35', '62']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'res_w'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '25'], 'value': '+'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '*'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'rotation'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '*'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'rotation'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'res_h'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '52'], 'value': '+'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '*'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'rotation'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '*'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'rotation'}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'expression_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'res_w'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'res_h'}
|
calculate the actual dimensions after rotation
|
def resourcetypes(rid, model):
types = []
for o, r, t, a in model.match(rid, VTYPE_REL):
types.append(t)
return types
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resourcetypes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'rid'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '32']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '17', '24']}; {'id': '12', 'type': 'pattern_list', 'children': ['13', '14', '15', '16']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'rid'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'VTYPE_REL'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'types'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'types'}
|
Return a list of Versa types for a resource
|
def benchmark(store, n=10000):
x = UpdatableItem(store=store, count=0)
for _ in xrange(n):
x.count += 1
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'benchmark'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '10000'}; {'id': '8', 'type': 'block', 'children': ['9', '21']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'UpdatableItem'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'store'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '27']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'augmented_assignment', 'children': ['30', '33'], 'value': '+='}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}
|
Increments an integer count n times.
|
def walk_preorder(self):
yield self
for child in self._children():
for descendant in child.walk_preorder():
yield descendant
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'walk_preorder'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '9']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'yield', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '16']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'child'}; {'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': '_children'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '24']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'descendant'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'walk_preorder'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'yield', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'descendant'}
|
Iterates the program tree starting from this object, going down.
|
def lee_yeast_ChIP(data_set='lee_yeast_ChIP'):
if not data_available(data_set):
download_data(data_set)
from pandas import read_csv
dir_path = os.path.join(data_path, data_set)
filename = os.path.join(dir_path, 'binding_by_gene.tsv')
S = read_csv(filename, header=1, index_col=0, sep='\t')
transcription_factors = [col for col in S.columns if col[:7] != 'Unnamed']
annotations = S[['Unnamed: 1', 'Unnamed: 2', 'Unnamed: 3']]
S = S[transcription_factors]
return data_details_return({'annotations' : annotations, 'Y' : S, 'transcription_factors': transcription_factors}, data_set)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lee_yeast_ChIP'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data_set'}; {'id': '6', 'type': 'string', 'children': [], 'value': "'lee_yeast_ChIP'"}; {'id': '7', 'type': 'block', 'children': ['8', '20', '25', '37', '49', '65', '83', '92', '98']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'data_available'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data_set'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'download_data'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data_set'}; {'id': '20', 'type': 'import_from_statement', 'children': ['21', '23']}; {'id': '21', 'type': 'dotted_name', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pandas'}; {'id': '23', 'type': 'dotted_name', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'read_csv'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dir_path'}; {'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': 'os'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data_path'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'data_set'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'os'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dir_path'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'binding_by_gene.tsv'"}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'read_csv'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56', '59', '62']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'index_col'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'\\t'"}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'transcription_factors'}; {'id': '68', 'type': 'list_comprehension', 'children': ['69', '70', '75']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '70', 'type': 'for_in_clause', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '75', 'type': 'if_clause', 'children': ['76']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '82'], 'value': '!='}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '79', 'type': 'slice', 'children': ['80', '81']}; {'id': '80', 'type': 'colon', 'children': []}; {'id': '81', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '82', 'type': 'string', 'children': [], 'value': "'Unnamed'"}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'annotations'}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '88', 'type': 'list', 'children': ['89', '90', '91'], 'value': "['Unnamed: 1', 'Unnamed: 2', 'Unnamed: 3']"}; {'id': '89', 'type': 'string', 'children': [], 'value': "'Unnamed: 1'"}; {'id': '90', 'type': 'string', 'children': [], 'value': "'Unnamed: 2'"}; {'id': '91', 'type': 'string', 'children': [], 'value': "'Unnamed: 3'"}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'transcription_factors'}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'data_details_return'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '112']}; {'id': '102', 'type': 'dictionary', 'children': ['103', '106', '109']}; {'id': '103', 'type': 'pair', 'children': ['104', '105']}; {'id': '104', 'type': 'string', 'children': [], 'value': "'annotations'"}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'annotations'}; {'id': '106', 'type': 'pair', 'children': ['107', '108']}; {'id': '107', 'type': 'string', 'children': [], 'value': "'Y'"}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '109', 'type': 'pair', 'children': ['110', '111']}; {'id': '110', 'type': 'string', 'children': [], 'value': "'transcription_factors'"}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'transcription_factors'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'data_set'}
|
Yeast ChIP data from Lee et al.
|
def rollback(self):
if not self._in_transaction:
raise NotInTransaction
self._init_cache()
self._in_transaction = False
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rollback'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '20']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_in_transaction'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'raise_statement', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'NotInTransaction'}; {'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': '_init_cache'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_in_transaction'}; {'id': '25', 'type': 'False', 'children': []}
|
Drop changes from current transaction.
|
def _get_redis_keys_opts():
return {
'bank_prefix': __opts__.get('cache.redis.bank_prefix', _BANK_PREFIX),
'bank_keys_prefix': __opts__.get('cache.redis.bank_keys_prefix', _BANK_KEYS_PREFIX),
'key_prefix': __opts__.get('cache.redis.key_prefix', _KEY_PREFIX),
'separator': __opts__.get('cache.redis.separator', _SEPARATOR)
}
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_redis_keys_opts'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 'type': 'return_statement', 'children': ['6']}; {'id': '6', 'type': 'dictionary', 'children': ['7', '16', '25', '34']}; {'id': '7', 'type': 'pair', 'children': ['8', '9']}; {'id': '8', 'type': 'string', 'children': [], 'value': "'bank_prefix'"}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'cache.redis.bank_prefix'"}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_BANK_PREFIX'}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'bank_keys_prefix'"}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'cache.redis.bank_keys_prefix'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_BANK_KEYS_PREFIX'}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'key_prefix'"}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'cache.redis.key_prefix'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_KEY_PREFIX'}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'separator'"}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'cache.redis.separator'"}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_SEPARATOR'}
|
Build the key opts based on the user options.
|
def takeFromTree(self):
tree = self.treeWidget()
parent = self.parent()
if parent:
parent.takeChild(parent.indexOfChild(self))
else:
tree.takeTopLevelItem(tree.indexOfTopLevelItem(self))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'takeFromTree'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '22']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'treeWidget'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'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': 'parent'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '24', '37']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'takeChild'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'indexOfChild'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'else_clause', 'children': ['38']}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'takeTopLevelItem'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'indexOfTopLevelItem'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}
|
Takes this item from the tree.
|
def close(self):
try:
logger.debug('%s - closing', self._resource_name,
extra=self._logging_extra)
self.before_close()
self.visalib.close(self.session)
logger.debug('%s - is closed', self._resource_name,
extra=self._logging_extra)
self.session = None
except errors.InvalidSession:
pass
|
{'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']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '61']}; {'id': '7', 'type': 'block', 'children': ['8', '23', '29', '40', '55']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'%s - closing'"}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_resource_name'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_logging_extra'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'before_close'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'visalib'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'close'}; {'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': 'session'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '50']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'%s - is closed'"}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_resource_name'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_logging_extra'}; {'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': 'session'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'except_clause', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'InvalidSession'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'pass_statement', 'children': []}
|
Closes the VISA session and marks the handle as invalid.
|
def frame_msg(body, header=None, raw_body=False):
framed_msg = {}
if header is None:
header = {}
framed_msg['head'] = header
framed_msg['body'] = body
return salt.utils.msgpack.dumps(framed_msg)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'frame_msg'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'raw_body'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '16', '25', '31', '37']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'framed_msg'}; {'id': '15', 'type': 'dictionary', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'is'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '24', 'type': 'dictionary', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'framed_msg'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'head'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'framed_msg'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'body'"}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '46']}; {'id': '39', 'type': 'attribute', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'msgpack'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'framed_msg'}
|
Frame the given message with our wire protocol
|
def _validate(self):
for c, m in self.atom_to_seqres_sequence_maps.iteritems():
if self.seqres_to_uniparc_sequence_maps.keys():
atom_uniparc_keys = set(self.atom_to_uniparc_sequence_maps.get(c, {}).keys())
atom_seqres_keys = set(self.atom_to_seqres_sequence_maps.get(c, {}).keys())
assert(atom_uniparc_keys.intersection(atom_seqres_keys) == atom_uniparc_keys)
for k, v in m.map.iteritems():
uparc_id_1, uparc_id_2 = None, None
try:
uparc_id_1 = self.seqres_to_uniparc_sequence_maps[c].map[v]
uparc_id_2 = self.atom_to_uniparc_sequence_maps[c].map[k]
except:
continue
assert(uparc_id_1 == uparc_id_2)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '17']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'm'}; {'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': 'atom_to_seqres_sequence_maps'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'if_statement', 'children': ['19', '26']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'seqres_to_uniparc_sequence_maps'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27', '46', '65', '75']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'atom_uniparc_keys'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '45']}; {'id': '34', 'type': 'attribute', 'children': ['35', '44']}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'atom_to_uniparc_sequence_maps'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '43', 'type': 'dictionary', 'children': []}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'atom_seqres_keys'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '64']}; {'id': '53', 'type': 'attribute', 'children': ['54', '63']}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'atom_to_seqres_sequence_maps'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '62', 'type': 'dictionary', 'children': []}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'assert_statement', 'children': ['66']}; {'id': '66', 'type': '()', 'children': ['67']}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '74'], 'value': '=='}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'atom_uniparc_keys'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'intersection'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'atom_seqres_keys'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'atom_uniparc_keys'}; {'id': '75', 'type': 'for_statement', 'children': ['76', '79', '86']}; {'id': '76', 'type': 'pattern_list', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '85', 'type': 'argument_list', 'children': []}; {'id': '86', 'type': 'block', 'children': ['87', '95', '124']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '92']}; {'id': '89', 'type': 'pattern_list', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'uparc_id_1'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'uparc_id_2'}; {'id': '92', 'type': 'expression_list', 'children': ['93', '94']}; {'id': '93', 'type': 'None', 'children': []}; {'id': '94', 'type': 'None', 'children': []}; {'id': '95', 'type': 'try_statement', 'children': ['96', '121']}; {'id': '96', 'type': 'block', 'children': ['97', '109']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'uparc_id_1'}; {'id': '100', 'type': 'subscript', 'children': ['101', '108']}; {'id': '101', 'type': 'attribute', 'children': ['102', '107']}; {'id': '102', 'type': 'subscript', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'seqres_to_uniparc_sequence_maps'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'uparc_id_2'}; {'id': '112', 'type': 'subscript', 'children': ['113', '120']}; {'id': '113', 'type': 'attribute', 'children': ['114', '119']}; {'id': '114', 'type': 'subscript', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'atom_to_uniparc_sequence_maps'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '121', 'type': 'except_clause', 'children': ['122']}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'continue_statement', 'children': []}; {'id': '124', 'type': 'assert_statement', 'children': ['125']}; {'id': '125', 'type': '()', 'children': ['126']}; {'id': '126', 'type': 'comparison_operator', 'children': ['127', '128'], 'value': '=='}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'uparc_id_1'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'uparc_id_2'}
|
Tests that the maps agree through composition.
|
def create_unsigned_transaction(cls,
*,
nonce: int,
gas_price: int,
gas: int,
to: Address,
value: int,
data: bytes) -> 'BaseUnsignedTransaction':
return cls.get_transaction_class().create_unsigned_transaction(
nonce=nonce,
gas_price=gas_price,
gas=gas,
to=to,
value=value,
data=data
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_unsigned_transaction'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '10', '14', '18', '22', '26']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'keyword_separator', 'children': []}; {'id': '6', 'type': 'typed_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'nonce'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '10', 'type': 'typed_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'gas_price'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '14', 'type': 'typed_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'gas'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '18', 'type': 'typed_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'to'}; {'id': '20', 'type': 'type', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Address'}; {'id': '22', 'type': 'typed_parameter', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '24', 'type': 'type', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '26', 'type': 'typed_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '28', 'type': 'type', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '30', 'type': 'type', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'BaseUnsignedTransaction'"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '42']}; {'id': '35', 'type': 'attribute', 'children': ['36', '41']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get_transaction_class'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'create_unsigned_transaction'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46', '49', '52', '55', '58']}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'nonce'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'nonce'}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'gas_price'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'gas_price'}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'gas'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'gas'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'to'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'to'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'data'}
|
Proxy for instantiating an unsigned transaction for this VM.
|
def add_song(self, new_song, verbose=True):
if any([song.title == new_song.title for song in self._songs]):
if verbose:
print('{s} already in {a}, not adding song.'.format(s=new_song.title,
a=self.name))
return 1
if new_song.artist == self.name:
self._songs.append(new_song)
self._num_songs += 1
return 0
if verbose:
print("Can't add song by {b}, artist must be {a}.".format(b=new_song.artist,
a=self.name))
return 1
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_song'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'new_song'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '52', '78', '100']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '27']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'list_comprehension', 'children': ['15', '22']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '19'], 'value': '=='}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'song'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'new_song'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'song'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_songs'}; {'id': '27', 'type': 'block', 'children': ['28', '50']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'{s} already in {a}, not adding song.'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '45']}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'new_song'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '60']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '57'], 'value': '=='}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'new_song'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'artist'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'block', 'children': ['61', '70', '76']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '68']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_songs'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'new_song'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'augmented_assignment', 'children': ['72', '75'], 'value': '+='}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_num_songs'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'string', 'children': [], 'value': '"Can\'t add song by {b}, artist must be {a}."'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '95']}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'new_song'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'artist'}; {'id': '95', 'type': 'keyword_argument', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '100', 'type': 'return_statement', 'children': ['101']}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}
|
Add a Song object to the Artist object
|
def lists(self):
with open(self.filelist, 'w') as filelist:
with open(self.reportlist, 'w') as reportlist:
for sample in self.runmetadata.samples:
if self.extension == 'fastq':
try:
status = sample.run.Description
if status == 'metagenome':
filelist.write(sample.general.combined + '\n')
reportlist.write(sample.general.combined.split('.')[0] + '\n')
except AttributeError:
pass
else:
if sample.general.combined != 'NA':
filelist.write(sample.general.combined + '\n')
reportlist.write(sample.general.combined.split('.')[0] + '\n')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lists'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '19']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'as_pattern', 'children': ['10', '17']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'open'}; {'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': 'filelist'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '17', 'type': 'as_pattern_target', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'filelist'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'with_statement', 'children': ['21', '33']}; {'id': '21', 'type': 'with_clause', 'children': ['22']}; {'id': '22', 'type': 'with_item', 'children': ['23']}; {'id': '23', 'type': 'as_pattern', 'children': ['24', '31']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'reportlist'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '31', 'type': 'as_pattern_target', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'reportlist'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '41']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'runmetadata'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'samples'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'if_statement', 'children': ['43', '48', '101']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': '=='}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'extension'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'fastq'"}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'try_statement', 'children': ['50', '97']}; {'id': '50', 'type': 'block', 'children': ['51', '59']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '54', 'type': 'attribute', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'Description'}; {'id': '59', 'type': 'if_statement', 'children': ['60', '63']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': '=='}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'metagenome'"}; {'id': '63', 'type': 'block', 'children': ['64', '77']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'filelist'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '76'], 'value': '+'}; {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'reportlist'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '96'], 'value': '+'}; {'id': '84', 'type': 'subscript', 'children': ['85', '95']}; {'id': '85', 'type': 'call', 'children': ['86', '93']}; {'id': '86', 'type': 'attribute', 'children': ['87', '92']}; {'id': '87', 'type': 'attribute', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '95', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '97', 'type': 'except_clause', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'pass_statement', 'children': []}; {'id': '101', 'type': 'else_clause', 'children': ['102']}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'if_statement', 'children': ['104', '111']}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '110'], 'value': '!='}; {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '110', 'type': 'string', 'children': [], 'value': "'NA'"}; {'id': '111', 'type': 'block', 'children': ['112', '125']}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'filelist'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '124'], 'value': '+'}; {'id': '119', 'type': 'attribute', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '124', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'reportlist'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '130', 'type': 'argument_list', 'children': ['131']}; {'id': '131', 'type': 'binary_operator', 'children': ['132', '144'], 'value': '+'}; {'id': '132', 'type': 'subscript', 'children': ['133', '143']}; {'id': '133', 'type': 'call', 'children': ['134', '141']}; {'id': '134', 'type': 'attribute', 'children': ['135', '140']}; {'id': '135', 'type': 'attribute', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'combined'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '143', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '144', 'type': 'string', 'children': [], 'value': "'\\n'"}
|
Prepare the list of files to be processed
|
async def move_camera_spatial(self, position: Union[Point2, Point3]):
from s2clientprotocol import spatial_pb2 as spatial_pb
assert isinstance(position, (Point2, Point3))
action = sc_pb.Action(
action_render=spatial_pb.ActionSpatial(
camera_move=spatial_pb.ActionSpatialCameraMove(
center_minimap=common_pb.PointI(x=position.x, y=position.y)
)
)
)
await self._execute(action=sc_pb.RequestAction(actions=[action]))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move_camera_spatial'}; {'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': 'position'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'generic_type', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '10', 'type': 'type_parameter', 'children': ['11', '13']}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Point2'}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Point3'}; {'id': '15', 'type': 'block', 'children': ['16', '23', '31', '70']}; {'id': '16', 'type': 'import_from_statement', 'children': ['17', '19']}; {'id': '17', 'type': 'dotted_name', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 's2clientprotocol'}; {'id': '19', 'type': 'aliased_import', 'children': ['20', '22']}; {'id': '20', 'type': 'dotted_name', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'spatial_pb2'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'spatial_pb'}; {'id': '23', 'type': 'assert_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '28', 'type': 'tuple', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Point2'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Point3'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'sc_pb'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Action'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'action_render'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'spatial_pb'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ActionSpatial'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'camera_move'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'spatial_pb'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ActionSpatialCameraMove'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'center_minimap'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'common_pb'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'PointI'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '65']}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'await', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': '_execute'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'sc_pb'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'RequestAction'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '86', 'type': 'list', 'children': ['87'], 'value': '[action]'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'action'}
|
Moves camera to the target position using the spatial aciton interface
|
def from_file(fn, **options):
if hasattr(fn, 'read'):
return TableFu(fn, **options)
with open(fn) as f:
return TableFu(f, **options)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '7', 'type': 'block', 'children': ['8', '22']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'read'"}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'TableFu'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '20', 'type': 'dictionary_splat', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '22', 'type': 'with_statement', 'children': ['23', '32']}; {'id': '23', 'type': 'with_clause', 'children': ['24']}; {'id': '24', 'type': 'with_item', 'children': ['25']}; {'id': '25', 'type': 'as_pattern', 'children': ['26', '30']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '30', 'type': 'as_pattern_target', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'TableFu'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '38', 'type': 'dictionary_splat', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'options'}
|
Creates a new TableFu instance from a file or path
|
def render_to_png(self, filename=None, dpi=72, **kwargs):
import cairosvg
return cairosvg.svg2png(
bytestring=self.render(**kwargs), write_to=filename, dpi=dpi
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_to_png'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dpi'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '72'}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '13', 'type': 'block', 'children': ['14', '17']}; {'id': '14', 'type': 'import_statement', 'children': ['15']}; {'id': '15', 'type': 'dotted_name', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cairosvg'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cairosvg'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'svg2png'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '32', '35']}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'bytestring'}; {'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': 'render'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'dictionary_splat', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'write_to'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dpi'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'dpi'}
|
Render the graph, convert it to png and write it to filename
|
def add_cell(self, keypath, cell):
keypath = keypath[:]
inner = self
cellname = keypath
assert keypath not in self, "Already exists: %s " % (str(keypath))
if isinstance(keypath, list):
while len(keypath) > 1:
cellname = keypath.pop(0)
if cellname not in inner:
inner.__dict__['p'][cellname] = DictCell()
inner = inner[cellname]
cellname = keypath[0]
inner.__dict__['p'][cellname] = cell
return inner[cellname]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_cell'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '19', '23', '34', '87', '97']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '13', 'type': 'slice', 'children': ['14']}; {'id': '14', 'type': 'colon', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'inner'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cellname'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '23', 'type': 'assert_statement', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'not in'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '%'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"Already exists: %s "'}; {'id': '29', 'type': '()', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '40']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '40', 'type': 'block', 'children': ['41', '81']}; {'id': '41', 'type': 'while_statement', 'children': ['42', '48']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '47'], 'value': '>'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'block', 'children': ['49', '58', '75']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cellname'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '62']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': 'not in'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'cellname'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'inner'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '72']}; {'id': '65', 'type': 'subscript', 'children': ['66', '71']}; {'id': '66', 'type': 'subscript', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'inner'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'p'"}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'cellname'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'DictCell'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'inner'}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'inner'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'cellname'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'cellname'}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'keypath'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '96']}; {'id': '89', 'type': 'subscript', 'children': ['90', '95']}; {'id': '90', 'type': 'subscript', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'inner'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '94', 'type': 'string', 'children': [], 'value': "'p'"}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'cellname'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'cell'}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'inner'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'cellname'}
|
Adds a new cell to the end of `keypath` of type `cell`
|
def stop(self):
_logger.debug("Emitting quit signal for connections.")
self.__quit_ev.set()
_logger.info("Waiting for connection manager to stop.")
self.__manage_g.join()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '21', '28']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"Emitting quit signal for connections."'}; {'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': '__quit_ev'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '20', 'type': 'argument_list', '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': '_logger'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"Waiting for connection manager to stop."'}; {'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': '__manage_g'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '35', 'type': 'argument_list', 'children': []}
|
Stop all of the connections.
|
def remove_namespace(self, namespace):
params = (namespace, )
execute = self.cursor.execute
execute('DELETE FROM gauged_data WHERE namespace = %s', params)
execute('DELETE FROM gauged_statistics WHERE namespace = %s', params)
execute('DELETE FROM gauged_keys WHERE namespace = %s', params)
self.remove_cache(namespace)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_namespace'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '6', 'type': 'block', 'children': ['7', '12', '20', '26', '32', '38']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '10', 'type': 'tuple', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'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': 'cursor'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'DELETE FROM gauged_data WHERE namespace = %s'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'DELETE FROM gauged_statistics WHERE namespace = %s'"}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'DELETE FROM gauged_keys WHERE namespace = %s'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'params'}; {'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': 'remove_cache'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'namespace'}
|
Remove all data associated with the current namespace
|
def _init_go_sources(self, go_sources_arg, go2obj_arg):
gos_user = set(go_sources_arg)
if 'children' in self.kws and self.kws['children']:
gos_user |= get_leaf_children(gos_user, go2obj_arg)
gos_godag = set(go2obj_arg)
gos_source = gos_user.intersection(gos_godag)
gos_missing = gos_user.difference(gos_godag)
if not gos_missing:
return gos_source
sys.stdout.write("{N} GO IDs NOT FOUND IN GO DAG: {GOs}\n".format(
N=len(gos_missing), GOs=" ".join([str(e) for e in gos_missing])))
return gos_source
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_go_sources'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'go_sources_arg'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'go2obj_arg'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '36', '43', '52', '61', '67', '101']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'gos_user'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'go_sources_arg'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '27']}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '22'], 'value': 'and'}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'in'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'children'"}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kws'}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kws'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'children'"}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'augmented_assignment', 'children': ['30', '31'], 'value': '|='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'gos_user'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get_leaf_children'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'gos_user'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'go2obj_arg'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'gos_godag'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'go2obj_arg'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'gos_source'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'gos_user'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'intersection'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'gos_godag'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'gos_missing'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'gos_user'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'difference'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'gos_godag'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '64']}; {'id': '62', 'type': 'not_operator', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'gos_missing'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'gos_source'}; {'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': 'sys'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': '"{N} GO IDs NOT FOUND IN GO DAG: {GOs}\\n"'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '86']}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'gos_missing'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'GOs'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'list_comprehension', 'children': ['94', '98']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '98', 'type': 'for_in_clause', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'gos_missing'}; {'id': '101', 'type': 'return_statement', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'gos_source'}
|
Return GO sources which are present in GODag.
|
def create_folder(self, folder):
if folder.endswith("/"):
folder = folder[:-1]
if len(folder) < 1:
raise Exception("Minimum folder name length = 1.")
if not os.path.exists(folder):
try:
os.makedirs(folder)
except Exception:
pass
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_folder'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '6', 'type': 'block', 'children': ['7', '24', '37']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': '"/"'}; {'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': 'folder'}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '20', 'type': 'slice', 'children': ['21', '22']}; {'id': '21', 'type': 'colon', 'children': []}; {'id': '22', 'type': 'unary_operator', 'children': ['23'], 'value': '-'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'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': 'folder'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'raise_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"Minimum folder name length = 1."'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '47']}; {'id': '38', 'type': 'not_operator', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'try_statement', 'children': ['49', '57']}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'folder'}; {'id': '57', 'type': 'except_clause', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'pass_statement', 'children': []}
|
Creates a folder of the given name if it doesn't already exist.
|
def runtime_paths(self):
runtimepath = self._vim.options['runtimepath']
plugin = "ensime-vim"
paths = []
for path in runtimepath.split(','):
if plugin in path:
paths.append(os.path.expanduser(path))
return paths
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'runtime_paths'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '20', '24', '52']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'runtimepath'}; {'id': '9', 'type': 'subscript', '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': '_vim'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'runtimepath'"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"ensime-vim"'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'paths'}; {'id': '23', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '24', 'type': 'for_statement', 'children': ['25', '26', '32']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'runtimepath'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "','"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'in'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'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': 'paths'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '43', 'type': 'argument_list', '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': 'os'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'paths'}
|
All the runtime paths of ensime-vim plugin files.
|
def write_int(self, value):
format = '!I'
self.data.append(struct.pack(format, int(value)))
self.size += 4
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_int'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '29']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'!I'"}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'augmented_assignment', 'children': ['31', '34'], 'value': '+='}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '4'}
|
Writes an unsigned integer to the packet
|
def get(self, timeout=None):
result = None
for stage in self._output_stages:
result = stage.get(timeout)
return result
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'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': 'timeout'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '13', '28']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'stage'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_output_stages'}; {'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': 'result'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'stage'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'result'}
|
Return result from the pipeline.
|
def _list_directory(self, folder_id=''):
title = '%s._list_directory' % self.__class__.__name__
file_list = []
list_kwargs = {
'spaces': self.drive_space,
'fields': 'nextPageToken, files(id, name, parents, mimeType)'
}
if folder_id:
list_kwargs['q'] = "'%s' in parents" % folder_id
if not self.space_id:
self._get_space()
page_token = 1
while page_token:
try:
response = self.drive.list(**list_kwargs).execute()
except:
raise DriveConnectionError(title)
results = response.get('files', [])
for file in results:
if not folder_id and file.get('parents', [])[0] != self.space_id:
pass
else:
yield file.get('id', ''), file.get('name', ''), file.get('mimeType', '')
page_token = response.get('nextPageToken', None)
if page_token:
list_kwargs['pageToken'] = page_token
return file_list
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_list_directory'}; {'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': 'folder_id'}; {'id': '7', 'type': 'string', 'children': [], 'value': "''"}; {'id': '8', 'type': 'block', 'children': ['9', '19', '23', '35', '46', '58', '62', '168']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '14'], 'value': '%'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'%s._list_directory'"}; {'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': '__class__'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'file_list'}; {'id': '22', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'list_kwargs'}; {'id': '26', 'type': 'dictionary', 'children': ['27', '32']}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'spaces'"}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'drive_space'}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'fields'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'nextPageToken, files(id, name, parents, mimeType)'"}; {'id': '35', 'type': 'if_statement', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'folder_id'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '43']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'list_kwargs'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'q'"}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '%'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"\'%s\' in parents"'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'folder_id'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '51']}; {'id': '47', 'type': 'not_operator', 'children': ['48']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'space_id'}; {'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': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_get_space'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'page_token'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'while_statement', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'page_token'}; {'id': '64', 'type': 'block', 'children': ['65', '90', '100', '149', '159']}; {'id': '65', 'type': 'try_statement', 'children': ['66', '83']}; {'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': 'response'}; {'id': '70', 'type': 'call', 'children': ['71', '82']}; {'id': '71', 'type': 'attribute', 'children': ['72', '81']}; {'id': '72', 'type': 'call', 'children': ['73', '78']}; {'id': '73', 'type': 'attribute', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'drive'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'dictionary_splat', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'list_kwargs'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '82', 'type': 'argument_list', 'children': []}; {'id': '83', 'type': 'except_clause', 'children': ['84']}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'raise_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'DriveConnectionError'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'files'"}; {'id': '99', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '100', 'type': 'for_statement', 'children': ['101', '102', '103']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'if_statement', 'children': ['105', '121', '123']}; {'id': '105', 'type': 'boolean_operator', 'children': ['106', '108'], 'value': 'and'}; {'id': '106', 'type': 'not_operator', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'folder_id'}; {'id': '108', 'type': 'comparison_operator', 'children': ['109', '118'], 'value': '!='}; {'id': '109', 'type': 'subscript', 'children': ['110', '117']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '116']}; {'id': '115', 'type': 'string', 'children': [], 'value': "'parents'"}; {'id': '116', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '117', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'space_id'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'pass_statement', 'children': []}; {'id': '123', 'type': 'else_clause', 'children': ['124']}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'yield', 'children': ['127']}; {'id': '127', 'type': 'expression_list', 'children': ['128', '135', '142']}; {'id': '128', 'type': 'call', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '134']}; {'id': '133', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '134', 'type': 'string', 'children': [], 'value': "''"}; {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141']}; {'id': '140', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '141', 'type': 'string', 'children': [], 'value': "''"}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '146', 'type': 'argument_list', 'children': ['147', '148']}; {'id': '147', 'type': 'string', 'children': [], 'value': "'mimeType'"}; {'id': '148', 'type': 'string', 'children': [], 'value': "''"}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'page_token'}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '156', 'type': 'argument_list', 'children': ['157', '158']}; {'id': '157', 'type': 'string', 'children': [], 'value': "'nextPageToken'"}; {'id': '158', 'type': 'None', 'children': []}; {'id': '159', 'type': 'if_statement', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'page_token'}; {'id': '161', 'type': 'block', 'children': ['162']}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}; {'id': '163', 'type': 'assignment', 'children': ['164', '167']}; {'id': '164', 'type': 'subscript', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'list_kwargs'}; {'id': '166', 'type': 'string', 'children': [], 'value': "'pageToken'"}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'page_token'}; {'id': '168', 'type': 'return_statement', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'file_list'}
|
a generator method for listing the contents of a directory
|
def _print_stats(cls, stats: Statistics, human_format_speed: bool=True):
time_length = datetime.timedelta(
seconds=int(stats.stop_time - stats.start_time)
)
file_size = wpull.string.format_size(stats.size)
if stats.bandwidth_meter.num_samples:
speed = stats.bandwidth_meter.speed()
if human_format_speed:
speed_size_str = wpull.string.format_size(speed)
else:
speed_size_str = '{:.1f} b'.format(speed * 8)
else:
speed_size_str = _('-- B')
_logger.info(_('FINISHED.'))
_logger.info(__(
_(
'Duration: {preformatted_timedelta}. '
'Speed: {preformatted_speed_size}/s.'
),
preformatted_timedelta=time_length,
preformatted_speed_size=speed_size_str,
))
_logger.info(__(
gettext.ngettext(
'Downloaded: {num_files} file, {preformatted_file_size}.',
'Downloaded: {num_files} files, {preformatted_file_size}.',
stats.files
),
num_files=stats.files,
preformatted_file_size=file_size
))
if stats.is_quota_exceeded:
_logger.info(_('Download quota exceeded.'))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_print_stats'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Statistics'}; {'id': '9', 'type': 'typed_default_parameter', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'human_format_speed'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '35', '48', '101', '111', '132', '159']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'time_length'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '32'], 'value': '-'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'stop_time'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'file_size'}; {'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': 'wpull'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'format_size'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '54', '92']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'bandwidth_meter'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'num_samples'}; {'id': '54', 'type': 'block', 'children': ['55', '65']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'speed'}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'bandwidth_meter'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'speed'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'if_statement', 'children': ['66', '67', '79']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'human_format_speed'}; {'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': 'speed_size_str'}; {'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': 'wpull'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'format_size'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'speed'}; {'id': '79', 'type': 'else_clause', 'children': ['80']}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'speed_size_str'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'{:.1f} b'"}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'binary_operator', 'children': ['90', '91'], 'value': '*'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'speed'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '92', 'type': 'else_clause', 'children': ['93']}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'speed_size_str'}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'-- B'"}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'string', 'children': [], 'value': "'FINISHED.'"}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': '__'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '126', '129']}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'concatenated_string', 'children': ['124', '125']}; {'id': '124', 'type': 'string', 'children': [], 'value': "'Duration: {preformatted_timedelta}. '"}; {'id': '125', 'type': 'string', 'children': [], 'value': "'Speed: {preformatted_speed_size}/s.'"}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'preformatted_timedelta'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'time_length'}; {'id': '129', 'type': 'keyword_argument', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'preformatted_speed_size'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'speed_size_str'}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': '__'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '151', '156']}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'gettext'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'ngettext'}; {'id': '145', 'type': 'argument_list', 'children': ['146', '147', '148']}; {'id': '146', 'type': 'string', 'children': [], 'value': "'Downloaded: {num_files} file, {preformatted_file_size}.'"}; {'id': '147', 'type': 'string', 'children': [], 'value': "'Downloaded: {num_files} files, {preformatted_file_size}.'"}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '151', 'type': 'keyword_argument', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'num_files'}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '156', 'type': 'keyword_argument', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'preformatted_file_size'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'file_size'}; {'id': '159', 'type': 'if_statement', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'is_quota_exceeded'}; {'id': '163', 'type': 'block', 'children': ['164']}; {'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': '_logger'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '169', 'type': 'argument_list', 'children': ['170']}; {'id': '170', 'type': 'call', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '172', 'type': 'argument_list', 'children': ['173']}; {'id': '173', 'type': 'string', 'children': [], 'value': "'Download quota exceeded.'"}
|
Log the final statistics to the user.
|
def on_exists(fname):
if os.path.isfile(fname):
newfile = fname + ".old"
print("{} -> {}".format(fname, newfile))
os.rename(fname, newfile)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '15', 'type': 'block', 'children': ['16', '22', '33']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'newfile'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '+'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '21', 'type': 'string', 'children': [], 'value': '".old"'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"{} -> {}"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'newfile'}; {'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': 'os'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'rename'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'newfile'}
|
Callback example when we try to overwrite an existing screenshot.
|
def make_analysator(f):
def text_analyse(text):
try:
rv = f(text)
except Exception:
return 0.0
if not rv:
return 0.0
try:
return min(1.0, max(0.0, float(rv)))
except (ValueError, TypeError):
return 0.0
text_analyse.__doc__ = f.__doc__
return staticmethod(text_analyse)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_analysator'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '5', 'type': 'block', 'children': ['6', '53', '61']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '10']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'text_analyse'}; {'id': '8', 'type': 'parameters', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '10', 'type': 'block', 'children': ['11', '25', '31']}; {'id': '11', 'type': 'try_statement', 'children': ['12', '20']}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'rv'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '20', 'type': 'except_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '28']}; {'id': '26', 'type': 'not_operator', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'rv'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '31', 'type': 'try_statement', 'children': ['32', '46']}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'rv'}; {'id': '46', 'type': 'except_clause', 'children': ['47', '50']}; {'id': '47', 'type': 'tuple', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'text_analyse'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'staticmethod'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'text_analyse'}
|
Return a static text analyser function that returns float values.
|
def off(self, name, callback, once=False):
if name not in self.event_listeners:
return
self.event_listeners[name].remove((callback, once))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'off'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'once'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '19']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '17']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'not in'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'event_listeners'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '28']}; {'id': '21', 'type': 'attribute', 'children': ['22', '27']}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'event_listeners'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'tuple', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'once'}
|
Removes callback to the event specified by name
|
def complete_object_value(
exe_context,
return_type,
field_asts,
info,
path,
result,
):
if return_type.is_type_of and not return_type.is_type_of(result, info):
raise GraphQLError(
u'Expected value of type "{}" but got: {}.'.format(
return_type, type(result).__name__
),
field_asts,
)
subfield_asts = exe_context.get_sub_fields(return_type, field_asts)
return execute_fields(exe_context, return_type, result, subfield_asts, path, info)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete_object_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'exe_context'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'return_type'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'field_asts'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '10', 'type': 'block', 'children': ['11', '42', '52']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '24']}; {'id': '12', 'type': 'boolean_operator', 'children': ['13', '16'], 'value': 'and'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'return_type'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'is_type_of'}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'return_type'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'is_type_of'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'GraphQLError'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '41']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': 'u\'Expected value of type "{}" but got: {}.\''}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'return_type'}; {'id': '35', 'type': 'attribute', 'children': ['36', '40']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'field_asts'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'subfield_asts'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'exe_context'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'get_sub_fields'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'return_type'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'field_asts'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'execute_fields'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57', '58', '59', '60', '61']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'exe_context'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'return_type'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'subfield_asts'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'info'}
|
Complete an Object value by evaluating all sub-selections.
|
def _generate_name(self, space, service_name, plan_name):
return str.join('-', [space, service_name, plan_name]).lower()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'space'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'service_name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'plan_name'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '23']}; {'id': '11', 'type': 'attribute', 'children': ['12', '22']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '18', 'type': 'list', 'children': ['19', '20', '21'], 'value': '[space, service_name, plan_name]'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'space'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'service_name'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'plan_name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '23', 'type': 'argument_list', 'children': []}
|
Can generate a name based on the space, service name and plan.
|
def from_jd(jd):
jd = trunc(jd) + 0.5
g = gregorian.from_jd(jd)
gy = g[0]
bstarty = EPOCH_GREGORIAN_YEAR
if jd <= gregorian.to_jd(gy, 3, 20):
x = 1
else:
x = 0
bys = gy - (bstarty + (((gregorian.to_jd(gy, 1, 1) <= jd) and x)))
year = bys + 1
days = jd - to_jd(year, 1, 1)
bld = to_jd(year, 20, 1)
if jd >= bld:
month = 20
else:
month = trunc(days / 19) + 1
day = int((jd + 1) - to_jd(year, month, 1))
return year, month, day
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_jd'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '24', '30', '34', '56', '79', '85', '96', '105', '127', '144']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '14'], 'value': '+'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'trunc'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '14', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'gregorian'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'from_jd'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'gy'}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'bstarty'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'EPOCH_GREGORIAN_YEAR'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '45', '50']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': '<='}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'gregorian'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'to_jd'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'gy'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '50', 'type': 'else_clause', 'children': ['51']}; {'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': 'x'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'bys'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '-'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'gy'}; {'id': '61', 'type': '()', 'children': ['62']}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '+'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'bstarty'}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': '()', 'children': ['66']}; {'id': '66', 'type': 'boolean_operator', 'children': ['67', '78'], 'value': 'and'}; {'id': '67', 'type': '()', 'children': ['68']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '77'], 'value': '<='}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'gregorian'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'to_jd'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75', '76']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'gy'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '82', 'type': 'binary_operator', 'children': ['83', '84'], 'value': '+'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'bys'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '88', 'type': 'binary_operator', 'children': ['89', '90'], 'value': '-'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'to_jd'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94', '95']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '95', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'bld'}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'to_jd'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103', '104']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '104', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '109', '114']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': '>='}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'bld'}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '113', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '114', 'type': 'else_clause', 'children': ['115']}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '126'], 'value': '+'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'trunc'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '125'], 'value': '/'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '125', 'type': 'integer', 'children': [], 'value': '19'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'assignment', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}; {'id': '133', 'type': 'binary_operator', 'children': ['134', '138'], 'value': '-'}; {'id': '134', 'type': '()', 'children': ['135']}; {'id': '135', 'type': 'binary_operator', 'children': ['136', '137'], 'value': '+'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'jd'}; {'id': '137', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'to_jd'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142', '143']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '143', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '144', 'type': 'return_statement', 'children': ['145']}; {'id': '145', 'type': 'expression_list', 'children': ['146', '147', '148']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'day'}
|
Calculate Bahai date from Julian day
|
def width_radius_changed_cb(self, widget, val):
self.width_radius = val
self.redraw_cuts()
self.replot_all()
return True
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'width_radius_changed_cb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'widget'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '20', '26']}; {'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': 'width_radius'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'val'}; {'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': 'redraw_cuts'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'replot_all'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'True', 'children': []}
|
Callback executed when the Width radius is changed.
|
def analysis_of_prot_lig_interactions(self):
self.hbonds = HBonds(self.topol_data,self.trajectory,self.start,self.end,self.skip,self.analysis_cutoff,distance=3)
self.pistacking = PiStacking(self.topol_data,self.trajectory,self.start,self.end,self.skip, self.analysis_cutoff)
self.sasa = SASA(self.topol_data,self.trajectory)
self.lig_descr = LigDescr(self.topol_data)
if self.trajectory!=[]:
self.rmsf = RMSF_measurements(self.topol_data,self.topology,self.trajectory,self.ligand,self.start,self.end,self.skip)
self.salt_bridges = SaltBridges(self.topol_data,self.trajectory,self.lig_descr,self.start,self.end,self.skip,self.analysis_cutoff)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'analysis_of_prot_lig_interactions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '35', '61', '75', '86', '122']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'hbonds'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'HBonds'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17', '20', '23', '26', '29', '32']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'topol_data'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'trajectory'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'skip'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'analysis_cutoff'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'distance'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'pistacking'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'PiStacking'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46', '49', '52', '55', '58']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'topol_data'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'trajectory'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'skip'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'analysis_cutoff'}; {'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': 'sasa'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'SASA'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'topol_data'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'trajectory'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'lig_descr'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'LigDescr'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'topol_data'}; {'id': '86', 'type': 'if_statement', 'children': ['87', '92']}; {'id': '87', 'type': 'comparison_operator', 'children': ['88', '91'], 'value': '!='}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'trajectory'}; {'id': '91', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'rmsf'}; {'id': '98', 'type': 'call', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'RMSF_measurements'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '104', '107', '110', '113', '116', '119']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'topol_data'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'topology'}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'trajectory'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'ligand'}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'skip'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'salt_bridges'}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'SaltBridges'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '133', '136', '139', '142', '145', '148']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'topol_data'}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'trajectory'}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'lig_descr'}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'skip'}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'analysis_cutoff'}
|
The classes and function that deal with protein-ligand interaction analysis.
|
def _push_status(data, item):
status = item['status'].lower()
if 'id' in item:
if 'already pushed' in status or 'already exists' in status:
already_pushed = data.setdefault('Layers', {}).setdefault(
'Already_Pushed', [])
already_pushed.append(item['id'])
elif 'successfully pushed' in status or status == 'pushed':
pushed = data.setdefault('Layers', {}).setdefault(
'Pushed', [])
pushed.append(item['id'])
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_push_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'item'}; {'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': 'status'}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'in'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '30', '56']}; {'id': '23', 'type': 'boolean_operator', 'children': ['24', '27'], 'value': 'or'}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'in'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'already pushed'"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'in'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'already exists'"}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '30', 'type': 'block', 'children': ['31', '47']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'already_pushed'}; {'id': '34', 'type': 'call', 'children': ['35', '44']}; {'id': '35', 'type': 'attribute', 'children': ['36', '43']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'Layers'"}; {'id': '42', 'type': 'dictionary', 'children': []}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'Already_Pushed'"}; {'id': '46', 'type': 'list', 'children': [], 'value': '[]'}; {'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': 'already_pushed'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '56', 'type': 'elif_clause', 'children': ['57', '64']}; {'id': '57', 'type': 'boolean_operator', 'children': ['58', '61'], 'value': 'or'}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'in'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'successfully pushed'"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '63'], 'value': '=='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'pushed'"}; {'id': '64', 'type': 'block', 'children': ['65', '81']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'pushed'}; {'id': '68', 'type': 'call', 'children': ['69', '78']}; {'id': '69', 'type': 'attribute', 'children': ['70', '77']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': "'Layers'"}; {'id': '76', 'type': 'dictionary', 'children': []}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "'Pushed'"}; {'id': '80', 'type': 'list', 'children': [], 'value': '[]'}; {'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': 'pushed'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '89', 'type': 'string', 'children': [], 'value': "'id'"}
|
Process a status update from a docker push, updating the data structure
|
def check_postconditions(f, return_value):
f = getattr(f, 'wrapped_fn', f)
if f and hasattr(f, 'postconditions'):
for cond in f.postconditions:
cond(return_value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_postconditions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'return_value'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14', '15']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'wrapped_fn'"}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '24']}; {'id': '17', 'type': 'boolean_operator', 'children': ['18', '19'], 'value': 'and'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'postconditions'"}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '30']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cond'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'postconditions'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cond'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'return_value'}
|
Runs all of the postconditions.
|
def time_since(self, mtype):
if not mtype in self.messages:
return time.time() - self.start_time
return time.time() - self.messages[mtype]._timestamp
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'time_since'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mtype'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'mtype'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'messages'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '22'], 'value': '-'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '32'], 'value': '-'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'attribute', 'children': ['33', '38']}; {'id': '33', 'type': 'subscript', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'messages'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'mtype'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_timestamp'}
|
return the time since the last message of type mtype was received
|
def list_i2str(ilist):
slist = []
for el in ilist:
slist.append(str(el))
return slist
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_i2str'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ilist'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'ilist'}; {'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': 'slist'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'el'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'slist'}
|
Convert an integer list into a string list.
|
def main(args=None):
streamsx._streams._version._mismatch_check('streamsx.topology.context')
try:
sr = run_cmd(args)
sr['return_code'] = 0
except:
sr = {'return_code':1, 'error': sys.exc_info()}
return sr
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '19', '50']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'streamsx'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_streams'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_version'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_mismatch_check'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'streamsx.topology.context'"}; {'id': '19', 'type': 'try_statement', 'children': ['20', '34']}; {'id': '20', 'type': 'block', 'children': ['21', '28']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sr'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'run_cmd'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sr'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'return_code'"}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '34', 'type': 'except_clause', 'children': ['35']}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'sr'}; {'id': '39', 'type': 'dictionary', 'children': ['40', '43']}; {'id': '40', 'type': 'pair', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'return_code'"}; {'id': '42', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'exc_info'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sr'}
|
Performs an action against a Streaming Analytics service.
|
def dump_ckan(m):
doc = MetapackDoc(cache=m.cache)
doc.new_section('Groups', 'Title Description Id Image_url'.split())
doc.new_section('Organizations', 'Title Description Id Image_url'.split())
c = RemoteCKAN(m.ckan_url, apikey=m.api_key)
for g in c.action.group_list(all_fields=True):
print(g.keys())
for o in c.action.organization_list(all_fields=True):
print(g.keys())
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump_ckan'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '29', '41', '55', '77']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'MetapackDoc'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'keyword_argument', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'new_section'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'Groups'"}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'Title Description Id Image_url'"}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'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': 'doc'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'new_section'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'Organizations'"}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'Title Description Id Image_url'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'RemoteCKAN'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ckan_url'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'apikey'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'api_key'}; {'id': '55', 'type': 'for_statement', 'children': ['56', '57', '67']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '57', 'type': 'call', 'children': ['58', '63']}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'group_list'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'all_fields'}; {'id': '66', 'type': 'True', 'children': []}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '76', 'type': 'argument_list', 'children': []}; {'id': '77', 'type': 'for_statement', 'children': ['78', '79', '89']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'organization_list'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'all_fields'}; {'id': '88', 'type': 'True', 'children': []}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '98', 'type': 'argument_list', 'children': []}
|
Create a groups and organization file
|
def _get_deltas(event):
delta_x = round(event.deltaX())
delta_y = round(event.deltaY())
delta_z = round(event.deltaZ())
return delta_x, delta_y, delta_z
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_deltas'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '28', '39']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'delta_x'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'deltaX'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'delta_y'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'deltaY'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'delta_z'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'deltaZ'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'expression_list', 'children': ['41', '42', '43']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'delta_x'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'delta_y'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'delta_z'}
|
Get the changes from the appkit event.
|
def make_client(api_version, session=None,
endpoint=None, service_type='monitoring'):
client_cls = utils.get_client_class('monitoring', api_version, VERSION_MAP)
c = client_cls(
session=session,
service_type=service_type,
endpoint=endpoint,
app_name='monascaclient',
app_version=version.version_string,
)
return c
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_client'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'api_version'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'service_type'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'monitoring'"}; {'id': '14', 'type': 'block', 'children': ['15', '26', '49']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'client_cls'}; {'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': 'get_client_class'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'monitoring'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'api_version'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'VERSION_MAP'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'client_cls'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '35', '38', '41', '44']}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'service_type'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'service_type'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'endpoint'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'app_name'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'monascaclient'"}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'app_version'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'version_string'}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'c'}
|
Returns an monitoring API client.
|
def ca_main_axis(self):
try:
ca_ind = self.dim_types.index(DT.CA_SUBVAR)
return 1 - ca_ind
except ValueError:
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ca_main_axis'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '25']}; {'id': '7', 'type': 'block', 'children': ['8', '21']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ca_ind'}; {'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': 'dim_types'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'DT'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'CA_SUBVAR'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '-'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ca_ind'}; {'id': '25', 'type': 'except_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'None', 'children': []}
|
For univariate CA, the main axis is the categorical axis
|
def minizinc_version():
vs = _run_minizinc('--version')
m = re.findall('version ([\d\.]+)', vs)
if not m:
raise RuntimeError('MiniZinc executable not found.')
return m[0]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'minizinc_version'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '12', '22', '31']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_run_minizinc'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'--version'"}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'm'}; {'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': 'findall'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'version ([\\d\\.]+)'"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '25']}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'MiniZinc executable not found.'"}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}
|
Returns the version of the found minizinc executable.
|
def parents(self, node):
return [
parent for parent in
getattr( node, 'parents', [] )
if getattr(parent, 'tree', self.TREE) == self.TREE
]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parents'}; {'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']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'list_comprehension', 'children': ['9', '10', '18']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '10', 'type': 'for_in_clause', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '17']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'parents'"}; {'id': '17', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '18', 'type': 'if_clause', 'children': ['19']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '28'], 'value': '=='}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'tree'"}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'TREE'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'TREE'}
|
Determine all parents of node in our tree
|
def parse(cls, string):
match = re.match(r'^(?P<name>[A-Za-z0-9\.\-_]+)\s+' +
'(?P<value>[0-9\.]+)\s+' +
'(?P<timestamp>[0-9\.]+)(\n?)$',
string)
try:
groups = match.groupdict()
return Metric(groups['name'],
groups['value'],
float(groups['timestamp']))
except:
raise DiamondException(
"Metric could not be parsed from string: %s." % string)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '6', 'type': 'block', 'children': ['7', '21']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '20']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '19'], 'value': '+'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '+'}; {'id': '17', 'type': 'string', 'children': [], 'value': "r'^(?P<name>[A-Za-z0-9\\.\\-_]+)\\s+'"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'(?P<value>[0-9\\.]+)\\s+'"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'(?P<timestamp>[0-9\\.]+)(\\n?)$'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '21', 'type': 'try_statement', 'children': ['22', '47']}; {'id': '22', 'type': 'block', 'children': ['23', '31']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Metric'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '38', '41']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'timestamp'"}; {'id': '47', 'type': 'except_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'raise_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'DiamondException'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '%'}; {'id': '54', 'type': 'string', 'children': [], 'value': '"Metric could not be parsed from string: %s."'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'string'}
|
Parse a string and create a metric
|
def post(self, path, payload):
body = json.dumps(payload)
return self._request(path, 'POST', body)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '7', 'type': 'block', 'children': ['8', '17']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'body'}; {'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']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_request'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'POST'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'body'}
|
Make a POST request from the API.
|
def weighted_choice(population):
random_number = random.betavariate(1, 2.5)
ind = int(random_number*len(population))
ind = min(max(ind, 0), len(population)-1)
return population[ind][0]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'weighted_choice'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '28', '45']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'random_number'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'betavariate'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'float', 'children': [], 'value': '2.5'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '*'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'random_number'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '39']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '44'], 'value': '-'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'subscript', 'children': ['47', '50']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'population'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}
|
Randomly select, fitness determines probability of being selected
|
def region_name(self, language=DEFAULT_LANGUAGE, min_score: int=75) -> str:
return self._get_name('region', language, min_score)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'region_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_LANGUAGE'}; {'id': '8', 'type': 'typed_default_parameter', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'min_score'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '75'}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_get_name'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'region'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'min_score'}
|
Describe the region part of the language tag in a natural language.
|
def _subst_libs(env, libs):
if SCons.Util.is_String(libs):
libs = env.subst(libs)
if SCons.Util.is_String(libs):
libs = libs.split()
elif SCons.Util.is_Sequence(libs):
_libs = []
for l in libs:
_libs += _subst_libs(env, l)
libs = _libs
else:
libs = [libs]
return libs
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_subst_libs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '6', 'type': 'block', 'children': ['7', '81']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '16', '44', '74']}; {'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': 'SCons'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'is_String'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '16', 'type': 'block', 'children': ['17', '26']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'subst'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '35']}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'SCons'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'is_String'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'elif_clause', 'children': ['45', '53']}; {'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': 'SCons'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Util'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'is_Sequence'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '53', 'type': 'block', 'children': ['54', '58', '70']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_libs'}; {'id': '57', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '58', 'type': 'for_statement', 'children': ['59', '60', '61']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'augmented_assignment', 'children': ['64', '65'], 'value': '+='}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_libs'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_subst_libs'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_libs'}; {'id': '74', 'type': 'else_clause', 'children': ['75']}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '79', 'type': 'list', 'children': ['80'], 'value': '[libs]'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'libs'}; {'id': '81', 'type': 'return_statement', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'libs'}
|
Substitute environment variables and split into list.
|
def widgetSubCheckBoxRect(widget, option):
opt = QtWidgets.QStyleOption()
opt.initFrom(widget)
style = widget.style()
return style.subElementRect(QtWidgets.QStyle.SE_ViewItemCheckIndicator, opt, widget)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'widgetSubCheckBoxRect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'widget'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'option'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '22', '30']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'QtWidgets'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'QStyleOption'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'initFrom'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'widget'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'widget'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'subElementRect'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '41', '42']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'QtWidgets'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'QStyle'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'SE_ViewItemCheckIndicator'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'widget'}
|
Returns the rectangle of a check box drawn as a sub element of widget
|
def facade(factory):
wrapper = FacadeDescriptor(factory.__name__, factory)
return update_wrapper(wrapper, factory)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'facade'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'factory'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'wrapper'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'FacadeDescriptor'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'factory'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'factory'}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'update_wrapper'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'wrapper'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'factory'}
|
Declare a method as a facade factory.
|
def _get_cursor(self):
_options = self._get_options()
conn = psycopg2.connect(host=_options['host'],
user=_options['user'],
password=_options['pass'],
dbname=_options['db'],
port=_options['port'])
cursor = conn.cursor()
try:
yield cursor
log.debug('Connected to POSTGRES DB')
except psycopg2.DatabaseError as err:
log.exception('Error in ext_pillar POSTGRES: %s', err.args)
finally:
conn.close()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_cursor'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '47', '55']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_get_options'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'psycopg2'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '27', '32', '37', '42']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'host'"}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'pass'"}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dbname'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'db'"}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_options'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'port'"}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'try_statement', 'children': ['56', '67', '85']}; {'id': '56', 'type': 'block', 'children': ['57', '60']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'yield', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'Connected to POSTGRES DB'"}; {'id': '67', 'type': 'except_clause', 'children': ['68', '74']}; {'id': '68', 'type': 'as_pattern', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'psycopg2'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'DatabaseError'}; {'id': '72', 'type': 'as_pattern_target', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': "'Error in ext_pillar POSTGRES: %s'"}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '85', 'type': 'finally_clause', 'children': ['86']}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '92', 'type': 'argument_list', 'children': []}
|
Yield a POSTGRES cursor
|
def approle_token(vault_client, role_id, secret_id):
resp = vault_client.auth_approle(role_id, secret_id)
if 'auth' in resp and 'client_token' in resp['auth']:
return resp['auth']['client_token']
else:
raise aomi.exceptions.AomiCredentials('invalid approle')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'approle_token'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'vault_client'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'role_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'secret_id'}; {'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': 'resp'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'vault_client'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'auth_approle'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'role_id'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'secret_id'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '28', '35']}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '23'], 'value': 'and'}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'in'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'auth'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'in'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'client_token'"}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'auth'"}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'subscript', 'children': ['31', '34']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'resp'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'auth'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'client_token'"}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'raise_statement', 'children': ['38']}; {'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': 'aomi'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'AomiCredentials'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'invalid approle'"}
|
Returns a vault token based on the role and seret id
|
def close_all_pages(self):
state_machine_m_list = [tab['state_machine_m'] for tab in self.tabs.values()]
for state_machine_m in state_machine_m_list:
self.on_close_clicked(None, state_machine_m, None, force=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close_all_pages'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '22']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'state_machine_m_list'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '13']}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tab'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'state_machine_m'"}; {'id': '13', 'type': 'for_in_clause', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tab'}; {'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': 'tabs'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'state_machine_m'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'state_machine_m_list'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'on_close_clicked'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '34', '35']}; {'id': '32', 'type': 'None', 'children': []}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'state_machine_m'}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '37', 'type': 'True', 'children': []}
|
Closes all tabs of the state machines editor.
|
def _select_md5sum_arch(self, md5sum, md5sum64):
if md5sum and md5sum64:
if self.meta.arch == "x86_64":
return md5sum64
else:
return md5sum
if md5sum:
return md5sum
else:
return md5sum64
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_select_md5sum_arch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'md5sum'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'md5sum64'}; {'id': '7', 'type': 'block', 'children': ['8', '28']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '11'], 'value': 'and'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'md5sum'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'md5sum64'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '21', '24']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '20'], 'value': '=='}; {'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': 'meta'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'arch'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"x86_64"'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'md5sum64'}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'md5sum'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '30', '33']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'md5sum'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'md5sum'}; {'id': '33', 'type': 'else_clause', 'children': ['34']}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'md5sum64'}
|
Return checksums by arch
|
def delete(self):
with self._qpart:
for cursor in self.cursors():
if cursor.hasSelection():
cursor.deleteChar()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_qpart'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '20']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'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': 'cursors'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '27']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hasSelection'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'deleteChar'}; {'id': '33', 'type': 'argument_list', 'children': []}
|
Del or Backspace pressed. Delete selection
|
def _parse_fail(name, var_type, value, values):
raise ValueError(
'Could not parse hparam \'%s\' of type \'%s\' with value \'%s\' in %s' %
(name, var_type.__name__, value, values))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_fail'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'var_type'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'raise_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '15'], 'value': '%'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'Could not parse hparam \\'%s\\' of type \\'%s\\' with value \\'%s\\' in %s'"}; {'id': '15', 'type': 'tuple', 'children': ['16', '17', '20', '21']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'var_type'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'values'}
|
Helper function for raising a value error for bad assignment.
|
def dict(self):
try:
skewness = self.skewness
kurtosis = self.kurtosis
except ZeroDivisionError:
skewness = kurtosis = float('nan')
base_cols = [
('name', self.column_name),
('flags', self.flags),
('type', self.type.__name__ ),
('lom', self.lom),
('count', self.n),
('nuniques', self.nuniques),
('width', self.size),
]
descriptive_cols = [
('mean', self.mean),
('std', self.stddev),
('min', self.min),
('p25', self.p25),
('p50', self.p50),
('p75', self.p75),
('max', self.max)
]
distribution_cols = [
('skewness', skewness),
('kurtosis', kurtosis),
('hist', self.bins),
('text_hist', text_hist(self.bins)),
]
sample_values_cols = [
('uvalues', self.uvalues)
]
return OrderedDict(
base_cols +
(descriptive_cols if self.descriptive else []) +
(distribution_cols if self.distribution else []) +
(sample_values_cols if self.sample_values else [])
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '32', '73', '112', '135', '144']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '20']}; {'id': '7', 'type': 'block', 'children': ['8', '14']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'skewness'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'skewness'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'kurtosis'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'kurtosis'}; {'id': '20', 'type': 'except_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ZeroDivisionError'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'skewness'}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kurtosis'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'nan'"}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'base_cols'}; {'id': '35', 'type': 'list', 'children': ['36', '41', '46', '53', '58', '63', '68'], 'value': "[\n ('name', self.column_name),\n ('flags', self.flags),\n ('type', self.type.__name__ ),\n ('lom', self.lom),\n ('count', self.n),\n ('nuniques', self.nuniques),\n ('width', self.size),\n ]"}; {'id': '36', 'type': 'tuple', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'column_name'}; {'id': '41', 'type': 'tuple', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'flags'"}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '46', 'type': 'tuple', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '53', 'type': 'tuple', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'lom'"}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'lom'}; {'id': '58', 'type': 'tuple', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'count'"}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '63', 'type': 'tuple', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'nuniques'"}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'nuniques'}; {'id': '68', 'type': 'tuple', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': "'width'"}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'descriptive_cols'}; {'id': '76', 'type': 'list', 'children': ['77', '82', '87', '92', '97', '102', '107'], 'value': "[\n ('mean', self.mean),\n ('std', self.stddev),\n ('min', self.min),\n ('p25', self.p25),\n ('p50', self.p50),\n ('p75', self.p75),\n ('max', self.max)\n ]"}; {'id': '77', 'type': 'tuple', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'mean'"}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '82', 'type': 'tuple', 'children': ['83', '84']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'std'"}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'stddev'}; {'id': '87', 'type': 'tuple', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': "'min'"}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '92', 'type': 'tuple', 'children': ['93', '94']}; {'id': '93', 'type': 'string', 'children': [], 'value': "'p25'"}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'p25'}; {'id': '97', 'type': 'tuple', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'p50'"}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'p50'}; {'id': '102', 'type': 'tuple', 'children': ['103', '104']}; {'id': '103', 'type': 'string', 'children': [], 'value': "'p75'"}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'p75'}; {'id': '107', 'type': 'tuple', 'children': ['108', '109']}; {'id': '108', 'type': 'string', 'children': [], 'value': "'max'"}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'distribution_cols'}; {'id': '115', 'type': 'list', 'children': ['116', '119', '122', '127'], 'value': "[\n ('skewness', skewness),\n ('kurtosis', kurtosis),\n ('hist', self.bins),\n ('text_hist', text_hist(self.bins)),\n ]"}; {'id': '116', 'type': 'tuple', 'children': ['117', '118']}; {'id': '117', 'type': 'string', 'children': [], 'value': "'skewness'"}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'skewness'}; {'id': '119', 'type': 'tuple', 'children': ['120', '121']}; {'id': '120', 'type': 'string', 'children': [], 'value': "'kurtosis'"}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'kurtosis'}; {'id': '122', 'type': 'tuple', 'children': ['123', '124']}; {'id': '123', 'type': 'string', 'children': [], 'value': "'hist'"}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '127', 'type': 'tuple', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': "'text_hist'"}; {'id': '129', 'type': 'call', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'text_hist'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'sample_values_cols'}; {'id': '138', 'type': 'list', 'children': ['139'], 'value': "[\n ('uvalues', self.uvalues)\n ]"}; {'id': '139', 'type': 'tuple', 'children': ['140', '141']}; {'id': '140', 'type': 'string', 'children': [], 'value': "'uvalues'"}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'uvalues'}; {'id': '144', 'type': 'return_statement', 'children': ['145']}; {'id': '145', 'type': 'call', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '147', 'type': 'argument_list', 'children': ['148']}; {'id': '148', 'type': 'binary_operator', 'children': ['149', '166'], 'value': '+'}; {'id': '149', 'type': 'binary_operator', 'children': ['150', '159'], 'value': '+'}; {'id': '150', 'type': 'binary_operator', 'children': ['151', '152'], 'value': '+'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'base_cols'}; {'id': '152', 'type': '()', 'children': ['153']}; {'id': '153', 'type': 'conditional_expression', 'children': ['154', '155', '158'], 'value': 'if'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'descriptive_cols'}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'descriptive'}; {'id': '158', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '159', 'type': '()', 'children': ['160']}; {'id': '160', 'type': 'conditional_expression', 'children': ['161', '162', '165'], 'value': 'if'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'distribution_cols'}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'distribution'}; {'id': '165', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '166', 'type': '()', 'children': ['167']}; {'id': '167', 'type': 'conditional_expression', 'children': ['168', '169', '172'], 'value': 'if'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'sample_values_cols'}; {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'sample_values'}; {'id': '172', 'type': 'list', 'children': [], 'value': '[]'}
|
Return a dict that can be passed into the ColumnStats constructor
|
def apply_selector(objs, selector):
out = []
for obj in objs:
timer.log('Applying selector: %s' % selector)
out += list(jsonselect.match(selector, objs))
timer.log('done applying selector')
return out
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply_selector'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '14', 'type': 'block', 'children': ['15', '24', '37']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'timer'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '%'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'Applying selector: %s'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'augmented_assignment', 'children': ['26', '27'], 'value': '+='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'list'}; {'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': 'jsonselect'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'selector'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'objs'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'timer'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'done applying selector'"}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'out'}
|
Returns a list of objects which match the selector in any of objs.
|
def delete(self, id):
path = partial(_path, self.adapter)
path = path(id)
return self._delete(path)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '24']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_path'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '24', 'type': 'return_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': '_delete'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}
|
delete a time entry.
|
def restart(self):
version = self.get_version()
command = [
"haproxy",
"-f", self.config_file_path, "-p", self.pid_file_path
]
if version and version >= (1, 5, 0):
command.extend(["-L", self.peer.name])
if os.path.exists(self.pid_file_path):
with open(self.pid_file_path) as fd:
command.extend(["-sf", fd.read().replace("\n", "")])
try:
output = subprocess.check_output(command)
except subprocess.CalledProcessError as e:
logger.error("Failed to restart HAProxy: %s", str(e))
return
if output:
logging.error("haproxy says: %s", output)
logger.info("Gracefully restarted HAProxy.")
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'restart'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '27', '50', '94', '125', '136']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_version'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '17', 'type': 'list', 'children': ['18', '19', '20', '23', '24'], 'value': '[\n "haproxy",\n "-f", self.config_file_path, "-p", self.pid_file_path\n ]'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"haproxy"'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"-f"'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'config_file_path'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"-p"'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pid_file_path'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '36']}; {'id': '28', 'type': 'boolean_operator', 'children': ['29', '30'], 'value': 'and'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': '>='}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '32', 'type': 'tuple', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'list', 'children': ['44', '45'], 'value': '["-L", self.peer.name]'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"-L"'}; {'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': 'peer'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '61']}; {'id': '51', 'type': 'call', 'children': ['52', '57']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pid_file_path'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'with_statement', 'children': ['63', '74']}; {'id': '63', 'type': 'with_clause', 'children': ['64']}; {'id': '64', 'type': 'with_item', 'children': ['65']}; {'id': '65', 'type': 'as_pattern', 'children': ['66', '72']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'open'}; {'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': 'pid_file_path'}; {'id': '72', 'type': 'as_pattern_target', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'fd'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'list', 'children': ['82', '83'], 'value': '["-sf", fd.read().replace("\\n", "")]'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"-sf"'}; {'id': '83', 'type': 'call', 'children': ['84', '91']}; {'id': '84', 'type': 'attribute', 'children': ['85', '90']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'fd'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '89', 'type': 'argument_list', 'children': []}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'string', 'children': [], 'value': '"\\n"'}; {'id': '93', 'type': 'string', 'children': [], 'value': '""'}; {'id': '94', 'type': 'try_statement', 'children': ['95', '105']}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'check_output'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '105', 'type': 'except_clause', 'children': ['106', '112']}; {'id': '106', 'type': 'as_pattern', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'CalledProcessError'}; {'id': '110', 'type': 'as_pattern_target', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '112', 'type': 'block', 'children': ['113', '124']}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120']}; {'id': '119', 'type': 'string', 'children': [], 'value': '"Failed to restart HAProxy: %s"'}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '124', 'type': 'return_statement', 'children': []}; {'id': '125', 'type': 'if_statement', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '127', 'type': 'block', 'children': ['128']}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '133', 'type': 'argument_list', 'children': ['134', '135']}; {'id': '134', 'type': 'string', 'children': [], 'value': '"haproxy says: %s"'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'string', 'children': [], 'value': '"Gracefully restarted HAProxy."'}
|
Performs a soft reload of the HAProxy process.
|
def _register_parser(cls):
assert cls.cls_msg_type is not None
assert cls.cls_msg_type not in _MSG_PARSERS
_MSG_PARSERS[cls.cls_msg_type] = cls.parser
return cls
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_register_parser'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '28']}; {'id': '6', 'type': 'assert_statement', 'children': ['7']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is not'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cls_msg_type'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'assert_statement', 'children': ['13']}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': 'not in'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cls_msg_type'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_MSG_PARSERS'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '25']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_MSG_PARSERS'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cls_msg_type'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'cls'}
|
class decorator to register msg parser
|
def _typedef_code(t, base=0, refs=None, kind=_kind_static, heap=False):
v = _Typedef(base=_basicsize(t, base=base),
refs=refs,
both=False, kind=kind, type=t)
v.save(t, base=base, heap=heap)
return v
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_typedef_code'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'refs'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_kind_static'}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'heap'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '45', '58']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_Typedef'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '33', '36', '39', '42']}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_basicsize'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'refs'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'refs'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'both'}; {'id': '38', 'type': 'False', 'children': []}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 't'}; {'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': 'v'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52', '55']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'base'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'heap'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'heap'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'v'}
|
Add new typedef for code only.
|
def fgmc(log_fg_ratios, mu_log_vt, sigma_log_vt, Rf, maxfg):
Lb = np.random.uniform(0., maxfg, len(Rf))
pquit = 0
while pquit < 0.1:
nsamp = len(Lb)
Rf_sel = np.random.choice(Rf, nsamp)
vt = np.random.lognormal(mu_log_vt, sigma_log_vt, len(Rf_sel))
Lf = Rf_sel * vt
log_Lf, log_Lb = log(Lf), log(Lb)
plR = 0
for lfr in log_fg_ratios:
plR += np.logaddexp(lfr + log_Lf, log_Lb)
plR -= (Lf + Lb)
plRn = plR - max(plR)
idx = np.exp(plRn) > np.random.random(len(plRn))
pquit = ss.stats.ks_2samp(Lb, Lb[idx])[1]
Lb = Lb[idx]
return Rf_sel[idx], Lf[idx], Lb
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fgmc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'log_fg_ratios'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mu_log_vt'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sigma_log_vt'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'Rf'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'maxfg'}; {'id': '9', 'type': 'block', 'children': ['10', '26', '30', '169']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'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': 'np'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'uniform'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'float', 'children': [], 'value': '0.'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'maxfg'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Rf'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'pquit'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'while_statement', 'children': ['31', '34']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': '<'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'pquit'}; {'id': '33', 'type': 'float', 'children': [], 'value': '0.1'}; {'id': '34', 'type': 'block', 'children': ['35', '42', '54', '70', '76', '90', '94', '110', '117', '126', '147', '163']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'nsamp'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'Rf_sel'}; {'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': 'np'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'choice'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'Rf'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'nsamp'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'vt'}; {'id': '57', 'type': 'call', 'children': ['58', '63']}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'lognormal'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65', '66']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'mu_log_vt'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sigma_log_vt'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'Rf_sel'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'Lf'}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '75'], 'value': '*'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'Rf_sel'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'vt'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'pattern_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'log_Lf'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'log_Lb'}; {'id': '81', 'type': 'expression_list', 'children': ['82', '86']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'Lf'}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'plR'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '94', 'type': 'for_statement', 'children': ['95', '96', '97']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'lfr'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'log_fg_ratios'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'augmented_assignment', 'children': ['100', '101'], 'value': '+='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'plR'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'logaddexp'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '109']}; {'id': '106', 'type': 'binary_operator', 'children': ['107', '108'], 'value': '+'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'lfr'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'log_Lf'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'log_Lb'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'augmented_assignment', 'children': ['112', '113'], 'value': '-='}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'plR'}; {'id': '113', 'type': '()', 'children': ['114']}; {'id': '114', 'type': 'binary_operator', 'children': ['115', '116'], 'value': '+'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'Lf'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'assignment', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'plRn'}; {'id': '120', 'type': 'binary_operator', 'children': ['121', '122'], 'value': '-'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'plR'}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'plR'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '129', 'type': 'comparison_operator', 'children': ['130', '136'], 'value': '>'}; {'id': '130', 'type': 'call', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'exp'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'plRn'}; {'id': '136', 'type': 'call', 'children': ['137', '142']}; {'id': '137', 'type': 'attribute', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'plRn'}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'pquit'}; {'id': '150', 'type': 'subscript', 'children': ['151', '162']}; {'id': '151', 'type': 'call', 'children': ['152', '157']}; {'id': '152', 'type': 'attribute', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'ss'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'stats'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'ks_2samp'}; {'id': '157', 'type': 'argument_list', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'id': '159', 'type': 'subscript', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '162', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'assignment', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'id': '166', 'type': 'subscript', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'Lb'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '169', 'type': 'return_statement', 'children': ['170']}; {'id': '170', 'type': 'expression_list', 'children': ['171', '174', '177']}; {'id': '171', 'type': 'subscript', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'Rf_sel'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '174', 'type': 'subscript', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'Lf'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'Lb'}
|
Function to fit the likelihood Fixme
|
def save_to_folders(self, parameter_space, folder_name, runs):
self.space_to_folders(self.db.get_results(), {}, parameter_space, runs,
folder_name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_to_folders'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parameter_space'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'folder_name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'space_to_folders'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '22', '23', '24', '25']}; {'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': 'db'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get_results'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'dictionary', 'children': []}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parameter_space'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'folder_name'}
|
Save results to a folder structure.
|
def bk_default(cls):
"Make the current background color the default."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.BACKGROUND_MASK
wAttributes &= ~win32.BACKGROUND_INTENSITY
cls._set_text_attributes(wAttributes)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bk_default'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '16', '23', '30']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Make the current background color the default."'}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'wAttributes'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_get_text_attributes'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'augmented_assignment', 'children': ['18', '19'], 'value': '&='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'wAttributes'}; {'id': '19', 'type': 'unary_operator', 'children': ['20'], 'value': '~'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'win32'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'BACKGROUND_MASK'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'augmented_assignment', 'children': ['25', '26'], 'value': '&='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'wAttributes'}; {'id': '26', 'type': 'unary_operator', 'children': ['27'], 'value': '~'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'win32'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'BACKGROUND_INTENSITY'}; {'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': 'cls'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_set_text_attributes'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'wAttributes'}
|
Make the current background color the default.
|
def import_gpg_key(key):
if not key:
raise CryptoritoError('Invalid GPG Key')
key_fd, key_filename = mkstemp("cryptorito-gpg-import")
key_handle = os.fdopen(key_fd, 'w')
key_handle.write(polite_string(key))
key_handle.close()
cmd = flatten([gnupg_bin(), gnupg_home(), "--import", key_filename])
output = stderr_output(cmd)
msg = 'gpg: Total number processed: 1'
output_bits = polite_string(output).split('\n')
return len([line for line in output_bits if line == msg]) == 1
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_gpg_key'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '24', '34', '44', '50', '65', '72', '76', '88']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'raise_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'CryptoritoError'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'Invalid GPG Key'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'key_fd'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key_filename'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'mkstemp'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"cryptorito-gpg-import"'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key_handle'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'fdopen'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'key_fd'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'key_handle'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'polite_string'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'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': 'key_handle'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'list', 'children': ['57', '60', '63', '64'], 'value': '[gnupg_bin(), gnupg_home(), "--import", key_filename]'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'gnupg_bin'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'gnupg_home'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'string', 'children': [], 'value': '"--import"'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'key_filename'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'stderr_output'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'gpg: Total number processed: 1'"}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'output_bits'}; {'id': '79', 'type': 'call', 'children': ['80', '86']}; {'id': '80', 'type': 'attribute', 'children': ['81', '85']}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'polite_string'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '102'], 'value': '=='}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'list_comprehension', 'children': ['94', '95', '98']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '95', 'type': 'for_in_clause', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'output_bits'}; {'id': '98', 'type': 'if_clause', 'children': ['99']}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '101'], 'value': '=='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '1'}
|
Imports a GPG key
|
def _apply_mask(
data: np.ndarray,
encoded_fill_values: list,
decoded_fill_value: Any,
dtype: Any,
) -> np.ndarray:
data = np.asarray(data, dtype=dtype)
condition = False
for fv in encoded_fill_values:
condition |= data == fv
return np.where(condition, decoded_fill_value, data)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_apply_mask'}; {'id': '3', 'type': 'parameters', 'children': ['4', '10', '14', '18']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '10', 'type': 'typed_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'encoded_fill_values'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '14', 'type': 'typed_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'decoded_fill_value'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Any'}; {'id': '18', 'type': 'typed_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '20', 'type': 'type', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Any'}; {'id': '22', 'type': 'type', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '26', 'type': 'block', 'children': ['27', '39', '43', '53']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'condition'}; {'id': '42', 'type': 'False', 'children': []}; {'id': '43', 'type': 'for_statement', 'children': ['44', '45', '46']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fv'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'encoded_fill_values'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'augmented_assignment', 'children': ['49', '50'], 'value': '|='}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'condition'}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': '=='}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'fv'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '61']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'condition'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'decoded_fill_value'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'data'}
|
Mask all matching values in a NumPy arrays.
|
def define_plugin_entry(name, module_name):
if isinstance(name, tuple):
entry, name = name
else:
entry = name
return '%s = %s:%s' % (entry, module_name, name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'define_plugin_entry'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'module_name'}; {'id': '6', 'type': 'block', 'children': ['7', '26']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '20']}; {'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': 'name'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'else_clause', 'children': ['21']}; {'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': 'entry'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '%'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'%s = %s:%s'"}; {'id': '29', 'type': 'tuple', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'module_name'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}
|
helper to produce lines suitable for setup.py's entry_points
|
def trips_process_xml():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
xml_str = body.get('xml_str')
tp = trips.process_xml(xml_str)
return _stmts_from_proc(tp)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trips_process_xml'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '29', '38', '47', '56']}; {'id': '5', 'type': 'if_statement', 'children': ['6', '11']}; {'id': '6', 'type': 'comparison_operator', 'children': ['7', '10'], 'value': '=='}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '10', 'type': 'string', 'children': [], 'value': "'OPTIONS'"}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'dictionary', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '17', 'type': 'call', 'children': ['18', '27']}; {'id': '18', 'type': 'attribute', 'children': ['19', '26']}; {'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': 'request'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'xml_str'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'xml_str'"}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'tp'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'trips'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'process_xml'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'xml_str'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_stmts_from_proc'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'tp'}
|
Process TRIPS EKB XML and return INDRA Statements.
|
def currency_multiplier(src_currency, dest_currency):
'returns equivalent value in USD for an amt of currency_code'
if src_currency == 'USD':
return 1.0
usd_mult = currency_rates()[src_currency]
if dest_currency == 'USD':
return usd_mult
return usd_mult/currency_rates()[dest_currency]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'currency_multiplier'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'src_currency'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dest_currency'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '16', '24', '31']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': "'returns equivalent value in USD for an amt of currency_code'"}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': '=='}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'src_currency'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'USD'"}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'usd_mult'}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'currency_rates'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'src_currency'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': '=='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dest_currency'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'USD'"}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'usd_mult'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '/'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'usd_mult'}; {'id': '34', 'type': 'subscript', 'children': ['35', '38']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'currency_rates'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dest_currency'}
|
returns equivalent value in USD for an amt of currency_code
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.