code
stringlengths 51
2.34k
| sequence
stringlengths 1.16k
13.1k
| docstring
stringlengths 11
171
|
|---|---|---|
def accept_transfer(transfer, comment=None):
TransferResponsePermission(transfer).test()
transfer.responded = datetime.now()
transfer.responder = current_user._get_current_object()
transfer.status = 'accepted'
transfer.response_comment = comment
transfer.save()
subject = transfer.subject
recipient = transfer.recipient
if isinstance(recipient, Organization):
subject.organization = recipient
elif isinstance(recipient, User):
subject.owner = recipient
subject.save()
return transfer
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'accept_transfer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '18', '28', '38', '44', '50', '56', '62', '68', '94', '100']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '17']}; {'id': '11', 'type': 'attribute', 'children': ['12', '16']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'TransferResponsePermission'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'responded'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'responder'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'current_user'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_get_current_object'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'accepted'"}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'response_comment'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'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': 'transfer'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'recipient'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'transfer'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'recipient'}; {'id': '68', 'type': 'if_statement', 'children': ['69', '74', '81']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'recipient'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'Organization'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'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': 'subject'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'organization'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'recipient'}; {'id': '81', 'type': 'elif_clause', 'children': ['82', '87']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '84', 'type': 'argument_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'recipient'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'owner'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'recipient'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '99', 'type': 'argument_list', 'children': []}; {'id': '100', 'type': 'return_statement', 'children': ['101']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'transfer'}
|
Accept an incoming a transfer request
|
def parse_problem(self, problem_content):
del problem_content["@order"]
return self.task_factory.get_problem_types().get(problem_content["type"]).parse_problem(problem_content)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_problem'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'problem_content'}; {'id': '6', 'type': 'block', 'children': ['7', '11']}; {'id': '7', 'type': 'delete_statement', 'children': ['8']}; {'id': '8', 'type': 'subscript', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'problem_content'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"@order"'}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '29']}; {'id': '13', 'type': 'attribute', 'children': ['14', '28']}; {'id': '14', 'type': 'call', 'children': ['15', '24']}; {'id': '15', 'type': 'attribute', 'children': ['16', '23']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'task_factory'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_problem_types'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'problem_content'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"type"'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'parse_problem'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'problem_content'}
|
Parses a problem, modifying some data
|
def find_by_text(text, _connection=None, page_size=100, page_number=0,
sort_by=enums.DEFAULT_SORT_BY, sort_order=enums.DEFAULT_SORT_ORDER):
return connection.ItemResultSet('find_videos_by_text',
Video, _connection, page_size, page_number, sort_by, sort_order,
text=text)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_by_text'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '19']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'page_size'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'page_number'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sort_by'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'enums'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_SORT_BY'}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sort_order'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'enums'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_SORT_ORDER'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ItemResultSet'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '33', '34', '35', '36', '37', '38']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'find_videos_by_text'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'Video'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'page_size'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'page_number'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'sort_by'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sort_order'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'text'}
|
List videos that match the ``text`` in title or description.
|
def char_range(starting_char, ending_char):
assert isinstance(starting_char, str), 'char_range: Wrong argument/s type'
assert isinstance(ending_char, str), 'char_range: Wrong argument/s type'
for char in range(ord(starting_char), ord(ending_char) + 1):
yield chr(char)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'char_range'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'starting_char'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ending_char'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '21']}; {'id': '7', 'type': 'assert_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'starting_char'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'char_range: Wrong argument/s type'"}; {'id': '14', 'type': 'assert_statement', 'children': ['15', '20']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'ending_char'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'char_range: Wrong argument/s type'"}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '36']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '30']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ord'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'starting_char'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '35'], 'value': '+'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ord'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ending_char'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'yield', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'chr'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'char'}
|
Create a range generator for chars
|
def source(self, source):
BaseView.source.fset(self, source)
if self.main_pane:
self.main_pane.object = self.contents
self.label_pane.object = self.label
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'BaseView'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'fset'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'main_pane'}; {'id': '21', 'type': 'block', 'children': ['22', '32']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'main_pane'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'contents'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', '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': 'label_pane'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'label'}
|
When the source gets updated, update the pane object
|
def unpack(src_dir, dst_dir):
for dirpath, dirnames, filenames in os.walk(src_dir):
subdir = os.path.relpath(dirpath, src_dir)
for f in filenames:
src = os.path.join(dirpath, f)
dst = os.path.join(dst_dir, subdir, f)
os.renames(src, dst)
for n, d in reversed(list(enumerate(dirnames))):
src = os.path.join(dirpath, d)
dst = os.path.join(dst_dir, subdir, d)
if not os.path.exists(dst):
os.renames(src, dst)
del dirnames[n]
for dirpath, dirnames, filenames in os.walk(src_dir, topdown=True):
assert not filenames
os.rmdir(dirpath)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unpack'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'src_dir'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dst_dir'}; {'id': '6', 'type': 'block', 'children': ['7', '131']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '12', '18']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dirnames'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'src_dir'}; {'id': '18', 'type': 'block', 'children': ['19', '31', '68']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'subdir'}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'relpath'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'src_dir'}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '34', 'type': 'block', 'children': ['35', '47', '60']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'dst'}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58', '59']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'dst_dir'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'subdir'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'f'}; {'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': 'os'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'renames'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'dst'}; {'id': '68', 'type': 'for_statement', 'children': ['69', '72', '82']}; {'id': '69', 'type': 'pattern_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'dirnames'}; {'id': '82', 'type': 'block', 'children': ['83', '95', '108']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '86', 'type': 'call', 'children': ['87', '92']}; {'id': '87', 'type': 'attribute', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'dst'}; {'id': '98', 'type': 'call', 'children': ['99', '104']}; {'id': '99', 'type': 'attribute', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106', '107']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'dst_dir'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'subdir'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '108', 'type': 'if_statement', 'children': ['109', '118']}; {'id': '109', 'type': 'not_operator', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '116']}; {'id': '111', 'type': 'attribute', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'dst'}; {'id': '118', 'type': 'block', 'children': ['119', '127']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'renames'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'dst'}; {'id': '127', 'type': 'delete_statement', 'children': ['128']}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'dirnames'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '131', 'type': 'for_statement', 'children': ['132', '136', '145']}; {'id': '132', 'type': 'pattern_list', 'children': ['133', '134', '135']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'dirpath'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'dirnames'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '136', 'type': 'call', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '140', 'type': 'argument_list', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'src_dir'}; {'id': '142', 'type': 'keyword_argument', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'topdown'}; {'id': '144', 'type': 'True', 'children': []}; {'id': '145', 'type': 'block', 'children': ['146', '149']}; {'id': '146', 'type': 'assert_statement', 'children': ['147']}; {'id': '147', 'type': 'not_operator', 'children': ['148']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'call', 'children': ['151', '154']}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'rmdir'}; {'id': '154', 'type': 'argument_list', 'children': ['155']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'dirpath'}
|
Move everything under `src_dir` to `dst_dir`, and delete the former.
|
def write_remaining(self):
if not self.results:
return
with db.execution_context():
with db.atomic():
Result.insert_many(self.results).execute()
del self.results[:]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_remaining'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '44']}; {'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': 'results'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': []}; {'id': '13', 'type': 'with_statement', 'children': ['14', '21']}; {'id': '14', 'type': 'with_clause', 'children': ['15']}; {'id': '15', 'type': 'with_item', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'execution_context'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'with_statement', 'children': ['23', '30']}; {'id': '23', 'type': 'with_clause', 'children': ['24']}; {'id': '24', 'type': 'with_item', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'atomic'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '43']}; {'id': '33', 'type': 'attribute', 'children': ['34', '42']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Result'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'insert_many'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'delete_statement', 'children': ['45']}; {'id': '45', 'type': 'subscript', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '49', 'type': 'slice', 'children': ['50']}; {'id': '50', 'type': 'colon', 'children': []}
|
Write the remaning stack content
|
def distclean(ctx=None):
global commands
lst=os.listdir('.')
for f in lst:
if f==Options.lockfile:
try:
proj=Environment.Environment(f)
except:
Logs.warn('could not read %r'%f)
continue
try:
shutil.rmtree(proj[BLDDIR])
except IOError:
pass
except OSError,e:
if e.errno!=errno.ENOENT:
Logs.warn('project %r cannot be removed'%proj[BLDDIR])
try:
os.remove(f)
except OSError,e:
if e.errno!=errno.ENOENT:
Logs.warn('file %r cannot be removed'%f)
if not commands and f.startswith('.waf'):
shutil.rmtree(f,ignore_errors=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distclean'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '10', '19']}; {'id': '8', 'type': 'global_statement', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'lst'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'listdir'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'lst'}; {'id': '22', 'type': 'block', 'children': ['23', '123']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '29']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': '=='}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Options'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'lockfile'}; {'id': '29', 'type': 'block', 'children': ['30', '53', '92']}; {'id': '30', 'type': 'try_statement', 'children': ['31', '41']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'proj'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Environment'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Environment'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '41', 'type': 'except_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43', '52']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Logs'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '%'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'could not read %r'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '52', 'type': 'continue_statement', 'children': []}; {'id': '53', 'type': 'try_statement', 'children': ['54', '64', '68']}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'shutil'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'rmtree'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'proj'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'BLDDIR'}; {'id': '64', 'type': 'except_clause', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'pass_statement', 'children': []}; {'id': '68', 'type': 'except_clause', 'children': ['69', '70', '71']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'if_statement', 'children': ['73', '80']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '77'], 'value': '!='}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ENOENT'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'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': 'Logs'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'binary_operator', 'children': ['88', '89'], 'value': '%'}; {'id': '88', 'type': 'string', 'children': [], 'value': "'project %r cannot be removed'"}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'proj'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'BLDDIR'}; {'id': '92', 'type': 'try_statement', 'children': ['93', '101']}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '101', 'type': 'except_clause', 'children': ['102', '103', '104']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'if_statement', 'children': ['106', '113']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '110'], 'value': '!='}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'errno'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'ENOENT'}; {'id': '113', 'type': 'block', 'children': ['114']}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'Logs'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'binary_operator', 'children': ['121', '122'], 'value': '%'}; {'id': '121', 'type': 'string', 'children': [], 'value': "'file %r cannot be removed'"}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '123', 'type': 'if_statement', 'children': ['124', '133']}; {'id': '124', 'type': 'boolean_operator', 'children': ['125', '127'], 'value': 'and'}; {'id': '125', 'type': 'not_operator', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'commands'}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'string', 'children': [], 'value': "'.waf'"}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'shutil'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'rmtree'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '141', 'type': 'keyword_argument', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'ignore_errors'}; {'id': '143', 'type': 'True', 'children': []}
|
removes the build directory
|
def _update_questions(self):
if self.is_simple_section():
return
part_list = self._get_parts()
if len(part_list) > len(self._my_map['assessmentParts']):
self._update_assessment_parts_map(part_list)
self._update_questions_list(part_list)
self._save()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_questions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '22']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'is_simple_section'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'part_list'}; {'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_parts'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '36']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '28'], 'value': '>'}; {'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': 'part_list'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_my_map'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'assessmentParts'"}; {'id': '36', 'type': 'block', 'children': ['37', '44', '51']}; {'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': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_update_assessment_parts_map'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'part_list'}; {'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': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_update_questions_list'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'part_list'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_save'}; {'id': '56', 'type': 'argument_list', 'children': []}
|
Updates questions known to this Section
|
def check_name(name, safe_chars):
regexp = re.compile('[^{0}]'.format(safe_chars))
if regexp.search(name):
raise SaltCloudException(
'{0} contains characters not supported by this cloud provider. '
'Valid characters are: {1}'.format(
name, safe_chars
)
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'safe_chars'}; {'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': 'regexp'}; {'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': 'compile'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'[^{0}]'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'safe_chars'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'regexp'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'raise_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'SaltCloudException'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'concatenated_string', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'{0} contains characters not supported by this cloud provider. '"}; {'id': '37', 'type': 'string', 'children': [], 'value': "'Valid characters are: {1}'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'safe_chars'}
|
Check whether the specified name contains invalid characters
|
def to(self, unit):
from astropy.units import rad
return (self.radians * rad).to(unit)
from astropy.coordinates import Angle
from astropy.units import rad
return Angle(self.radians, rad).to(unit)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '25', '31', '37']}; {'id': '7', 'type': 'import_from_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'dotted_name', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'astropy'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '11', 'type': 'dotted_name', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'rad'}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '23']}; {'id': '15', 'type': 'attribute', 'children': ['16', '22']}; {'id': '16', 'type': '()', 'children': ['17']}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '21'], 'value': '*'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'radians'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'rad'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'to'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'unit'}; {'id': '25', 'type': 'import_from_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'dotted_name', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'astropy'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'coordinates'}; {'id': '29', 'type': 'dotted_name', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Angle'}; {'id': '31', 'type': 'import_from_statement', 'children': ['32', '35']}; {'id': '32', 'type': 'dotted_name', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'astropy'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'units'}; {'id': '35', 'type': 'dotted_name', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'rad'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '48']}; {'id': '39', 'type': 'attribute', 'children': ['40', '47']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'Angle'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'radians'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'rad'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'to'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'unit'}
|
Convert this angle to the given AstroPy unit.
|
def view_global_gmfs(token, dstore):
imtls = dstore['oqparam'].imtls
row = dstore['gmf_data/data']['gmv'].mean(axis=0)
return rst_table([row], header=imtls)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'view_global_gmfs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dstore'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '30']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'imtls'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'subscript', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dstore'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'oqparam'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'imtls'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '18', 'type': 'call', 'children': ['19', '26']}; {'id': '19', 'type': 'attribute', 'children': ['20', '25']}; {'id': '20', 'type': 'subscript', 'children': ['21', '24']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'dstore'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'gmf_data/data'"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'gmv'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'rst_table'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '36']}; {'id': '34', 'type': 'list', 'children': ['35'], 'value': '[row]'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'imtls'}
|
Display GMFs averaged on everything for debugging purposes
|
def bind_end(self, stream, future):
if not isinstance(stream, Stream):
future.set_result(None)
else:
stream.pipe(TaskEndTransformer(future))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bind_end'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'future'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '15', '23']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Stream'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'future'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'set_result'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pipe'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'TaskEndTransformer'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'future'}
|
Bind a 'TaskEndTransformer' to a stream.
|
def find_bar_plot(ar, nth):
"Find the NTH barplot of the cluster in area AR."
for plot in ar.plots():
if isinstance(plot, T) and plot.cluster[0] == nth:
return plot
raise Exception("The %dth bar plot in the cluster not found." % nth)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_bar_plot'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ar'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'nth'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '34']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"Find the NTH barplot of the cluster in area AR."'}; {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '16']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ar'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'plots'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '31']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '24'], 'value': 'and'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '30'], 'value': '=='}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cluster'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'nth'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '34', 'type': 'raise_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '%'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"The %dth bar plot in the cluster not found."'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'nth'}
|
Find the NTH barplot of the cluster in area AR.
|
def _get_data(self, id_list, format='MLDataset'):
format = format.lower()
features = list()
for modality, data in self._modalities.items():
if format in ('ndarray', 'data_matrix'):
subset = np.array(itemgetter(*id_list)(data))
elif format in ('mldataset', 'pyradigm'):
subset = self._dataset.get_subset(id_list)
subset.data = { id_: data[id_] for id_ in id_list }
else:
raise ValueError('Invalid output format - choose only one of '
'MLDataset or data_matrix')
features.append(subset)
return features
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id_list'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'MLDataset'"}; {'id': '9', 'type': 'block', 'children': ['10', '18', '24', '107']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'features'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'for_statement', 'children': ['25', '28', '35']}; {'id': '25', 'type': 'pattern_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'modality'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '28', 'type': 'call', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_modalities'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36', '100']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '42', '59', '91']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'in'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '39', 'type': 'tuple', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'ndarray'"}; {'id': '41', 'type': 'string', 'children': [], 'value': "'data_matrix'"}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'subset'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '57']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'itemgetter'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'list_splat', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'id_list'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '59', 'type': 'elif_clause', 'children': ['60', '65']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': 'in'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '62', 'type': 'tuple', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'mldataset'"}; {'id': '64', 'type': 'string', 'children': [], 'value': "'pyradigm'"}; {'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': 'subset'}; {'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': '_dataset'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_subset'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'id_list'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'subset'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '82', 'type': 'dictionary_comprehension', 'children': ['83', '88']}; {'id': '83', 'type': 'pair', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '88', 'type': 'for_in_clause', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'id_'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'id_list'}; {'id': '91', 'type': 'else_clause', 'children': ['92']}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'raise_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'concatenated_string', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'Invalid output format - choose only one of '"}; {'id': '99', 'type': 'string', 'children': [], 'value': "'MLDataset or data_matrix'"}; {'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': 'features'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'subset'}; {'id': '107', 'type': 'return_statement', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'features'}
|
Returns the data, from all modalities, for a given list of IDs
|
def slistStr(slist):
slist = _fixSlist(slist)
string = ':'.join(['%02d' % x for x in slist[1:]])
return slist[0] + string
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'slistStr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '32']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_fixSlist'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '25']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '%'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'%02d'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '29', 'type': 'slice', 'children': ['30', '31']}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'colon', 'children': []}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '37'], 'value': '+'}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'slist'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'string'}
|
Converts signed list to angle string.
|
def getvariable(name):
import inspect
fr = inspect.currentframe()
try:
while fr:
fr = fr.f_back
vars = fr.f_locals
if name in vars:
return vars[name]
except:
pass
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getvariable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'block', 'children': ['6', '9', '17', '46']}; {'id': '6', 'type': 'import_statement', 'children': ['7']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fr'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'inspect'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'currentframe'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'try_statement', 'children': ['18', '43']}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'while_statement', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'fr'}; {'id': '21', 'type': 'block', 'children': ['22', '28', '34']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'fr'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'fr'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'f_back'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'fr'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'f_locals'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'in'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '43', 'type': 'except_clause', 'children': ['44']}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'pass_statement', 'children': []}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'None', 'children': []}
|
Get the value of a local variable somewhere in the call stack.
|
def clear_roles(user):
roles = get_user_roles(user)
for role in roles:
role.remove_role_from_user(user)
return roles
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_roles'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'roles'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'get_user_roles'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'roles'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'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': 'role'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'remove_role_from_user'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'roles'}
|
Remove all roles from a user.
|
def count(self, request, filter=None):
if filter is None:
filter = create_filter(request, self.mapped_class, self.geom_attr)
query = self.Session().query(self.mapped_class)
if filter is not None:
query = query.filter(filter)
return query.count()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '28', '43', '57']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '13', 'type': 'None', 'children': []}; {'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': 'filter'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'create_filter'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '25']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'mapped_class'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'geom_attr'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '31', 'type': 'call', 'children': ['32', '39']}; {'id': '32', 'type': 'attribute', 'children': ['33', '38']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Session'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'mapped_class'}; {'id': '43', 'type': 'if_statement', 'children': ['44', '47']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': 'is not'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '46', 'type': 'None', 'children': []}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '62', 'type': 'argument_list', 'children': []}
|
Return the number of records matching the given filter.
|
def next_blocks(self, quantity=-1):
blocks = (EighthBlock.objects.get_blocks_this_year().order_by(
"date", "block_letter").filter(Q(date__gt=self.date) | (Q(date=self.date) & Q(block_letter__gt=self.block_letter))))
if quantity == -1:
return blocks
return blocks[:quantity]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'next_blocks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'quantity'}; {'id': '7', 'type': 'unary_operator', 'children': ['8'], 'value': '-'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '9', 'type': 'block', 'children': ['10', '58', '66']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'blocks'}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '30']}; {'id': '15', 'type': 'attribute', 'children': ['16', '29']}; {'id': '16', 'type': 'call', 'children': ['17', '26']}; {'id': '17', 'type': 'attribute', 'children': ['18', '25']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'EighthBlock'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_blocks_this_year'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'order_by'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"date"'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"block_letter"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '40'], 'value': '|'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'date__gt'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '50'], 'value': '&'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'block_letter__gt'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'block_letter'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '63']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': '=='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'quantity'}; {'id': '61', 'type': 'unary_operator', 'children': ['62'], 'value': '-'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'blocks'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'blocks'}; {'id': '69', 'type': 'slice', 'children': ['70', '71']}; {'id': '70', 'type': 'colon', 'children': []}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'quantity'}
|
Get the next blocks in order.
|
def config(path=None, root=None, db=None):
import ambry.run
return ambry.run.load(path=path, root=root, db=db)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '18']}; {'id': '14', 'type': 'import_statement', 'children': ['15']}; {'id': '15', 'type': 'dotted_name', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ambry'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ambry'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '29', '32']}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'db'}
|
Return the default run_config object for this installation.
|
def _cosmoid_request(self, resource, cosmoid, **kwargs):
params = {
'cosmoid': cosmoid,
}
params.update(kwargs)
return self.make_request(resource, params)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cosmoid_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'cosmoid'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '17', '24']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '13', 'type': 'dictionary', 'children': ['14']}; {'id': '14', 'type': 'pair', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'cosmoid'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cosmoid'}; {'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': 'params'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'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': 'make_request'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'params'}
|
Maps to the Generic API method for requests who's only parameter is ``cosmoid``
|
def all_domain_events(self):
for originator_id in self.record_manager.all_sequence_ids():
for domain_event in self.get_domain_events(originator_id=originator_id, page_size=100):
yield domain_event
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'all_domain_events'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '15']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'originator_id'}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'record_manager'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'all_sequence_ids'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '29']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'domain_event'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_domain_events'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'originator_id'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'originator_id'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'page_size'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'yield', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'domain_event'}
|
Yields all domain events in the event store.
|
def _create_metadata_converter_action(self):
icon = resources_path('img', 'icons', 'show-metadata-converter.svg')
self.action_metadata_converter = QAction(
QIcon(icon),
self.tr('InaSAFE Metadata Converter'),
self.iface.mainWindow())
self.action_metadata_converter.setStatusTip(self.tr(
'Convert metadata from version 4.3 to version 3.5.'))
self.action_metadata_converter.setWhatsThis(self.tr(
'Use this tool to convert metadata 4.3 to version 3.5'))
self.action_metadata_converter.triggered.connect(
self.show_metadata_converter)
self.add_action(
self.action_metadata_converter, add_to_toolbar=self.full_toolbar)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_metadata_converter_action'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '40', '54', '68', '81']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'icon'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'resources_path'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'img'"}; {'id': '13', 'type': 'string', 'children': [], 'value': "'icons'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "'show-metadata-converter.svg'"}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'action_metadata_converter'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'QAction'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '27', '33']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'QIcon'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'icon'}; {'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': 'tr'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'InaSAFE Metadata Converter'"}; {'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': 'iface'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'mainWindow'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'action_metadata_converter'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'setStatusTip'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'tr'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'Convert metadata from version 4.3 to version 3.5.'"}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'action_metadata_converter'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'setWhatsThis'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'tr'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'Use this tool to convert metadata 4.3 to version 3.5'"}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '77']}; {'id': '70', 'type': 'attribute', 'children': ['71', '76']}; {'id': '71', 'type': 'attribute', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'action_metadata_converter'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'triggered'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'show_metadata_converter'}; {'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': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'add_action'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'action_metadata_converter'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'add_to_toolbar'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'full_toolbar'}
|
Create action for showing metadata converter dialog.
|
def _config_params(base_config, assoc_files, region, out_file, items):
params = []
dbsnp = assoc_files.get("dbsnp")
if dbsnp:
params += ["--dbsnp", dbsnp]
cosmic = assoc_files.get("cosmic")
if cosmic:
params += ["--cosmic", cosmic]
variant_regions = bedutils.population_variant_regions(items)
region = subset_variant_regions(variant_regions, region, out_file, items)
if region:
params += ["-L", bamprep.region_to_gatk(region), "--interval_set_rule",
"INTERSECTION"]
min_af = tz.get_in(["algorithm", "min_allele_fraction"], base_config)
if min_af:
params += ["--minimum_mutation_cell_fraction", "%.2f" % (min_af / 100.0)]
resources = config_utils.get_resources("mutect", base_config)
if resources.get("options") is not None:
params += [str(x) for x in resources.get("options", [])]
if "--enable_qscore_output" not in params:
params.append("--enable_qscore_output")
return params
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_config_params'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'base_config'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'assoc_files'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'out_file'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '9', 'type': 'block', 'children': ['10', '14', '23', '32', '41', '50', '59', '69', '85', '97', '111', '121', '148', '160']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '13', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dbsnp'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'assoc_files'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"dbsnp"'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dbsnp'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'augmented_assignment', 'children': ['28', '29'], 'value': '+='}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '29', 'type': 'list', 'children': ['30', '31'], 'value': '["--dbsnp", dbsnp]'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"--dbsnp"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'dbsnp'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'cosmic'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'assoc_files'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'string', 'children': [], 'value': '"cosmic"'}; {'id': '41', 'type': 'if_statement', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cosmic'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'augmented_assignment', 'children': ['46', '47'], 'value': '+='}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '47', 'type': 'list', 'children': ['48', '49'], 'value': '["--cosmic", cosmic]'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"--cosmic"'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cosmic'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'variant_regions'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'bedutils'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'population_variant_regions'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'subset_variant_regions'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66', '67', '68']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'variant_regions'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'out_file'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '69', 'type': 'if_statement', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'augmented_assignment', 'children': ['74', '75'], 'value': '+='}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '75', 'type': 'list', 'children': ['76', '77', '83', '84'], 'value': '["-L", bamprep.region_to_gatk(region), "--interval_set_rule",\n "INTERSECTION"]'}; {'id': '76', 'type': 'string', 'children': [], 'value': '"-L"'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'bamprep'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'region_to_gatk'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"--interval_set_rule"'}; {'id': '84', 'type': 'string', 'children': [], 'value': '"INTERSECTION"'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'min_af'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'get_in'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '96']}; {'id': '93', 'type': 'list', 'children': ['94', '95'], 'value': '["algorithm", "min_allele_fraction"]'}; {'id': '94', 'type': 'string', 'children': [], 'value': '"algorithm"'}; {'id': '95', 'type': 'string', 'children': [], 'value': '"min_allele_fraction"'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'base_config'}; {'id': '97', 'type': 'if_statement', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'min_af'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'augmented_assignment', 'children': ['102', '103'], 'value': '+='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '103', 'type': 'list', 'children': ['104', '105'], 'value': '["--minimum_mutation_cell_fraction", "%.2f" % (min_af / 100.0)]'}; {'id': '104', 'type': 'string', 'children': [], 'value': '"--minimum_mutation_cell_fraction"'}; {'id': '105', 'type': 'binary_operator', 'children': ['106', '107'], 'value': '%'}; {'id': '106', 'type': 'string', 'children': [], 'value': '"%.2f"'}; {'id': '107', 'type': '()', 'children': ['108']}; {'id': '108', 'type': 'binary_operator', 'children': ['109', '110'], 'value': '/'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'min_af'}; {'id': '110', 'type': 'float', 'children': [], 'value': '100.0'}; {'id': '111', 'type': 'expression_statement', 'children': ['112']}; {'id': '112', 'type': 'assignment', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'config_utils'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'get_resources'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120']}; {'id': '119', 'type': 'string', 'children': [], 'value': '"mutect"'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'base_config'}; {'id': '121', 'type': 'if_statement', 'children': ['122', '130']}; {'id': '122', 'type': 'comparison_operator', 'children': ['123', '129'], 'value': 'is not'}; {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'string', 'children': [], 'value': '"options"'}; {'id': '129', 'type': 'None', 'children': []}; {'id': '130', 'type': 'block', 'children': ['131']}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'augmented_assignment', 'children': ['133', '134'], 'value': '+='}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '134', 'type': 'list_comprehension', 'children': ['135', '139']}; {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '137', 'type': 'argument_list', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '139', 'type': 'for_in_clause', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '141', 'type': 'call', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '145', 'type': 'argument_list', 'children': ['146', '147']}; {'id': '146', 'type': 'string', 'children': [], 'value': '"options"'}; {'id': '147', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '148', 'type': 'if_statement', 'children': ['149', '152']}; {'id': '149', 'type': 'comparison_operator', 'children': ['150', '151'], 'value': 'not in'}; {'id': '150', 'type': 'string', 'children': [], 'value': '"--enable_qscore_output"'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '152', 'type': 'block', 'children': ['153']}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '158', 'type': 'argument_list', 'children': ['159']}; {'id': '159', 'type': 'string', 'children': [], 'value': '"--enable_qscore_output"'}; {'id': '160', 'type': 'return_statement', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'params'}
|
Add parameters based on configuration variables, associated files and genomic regions.
|
def _do_connect(self):
_, self._protocol = yield from self._loop.create_connection(
lambda: SnapcastProtocol(self._callbacks), self._host, self._port)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_do_connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '13']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_protocol'}; {'id': '13', 'type': 'yield', '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': '_loop'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'create_connection'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '28', '31']}; {'id': '21', 'type': 'lambda', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'SnapcastProtocol'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_callbacks'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_host'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_port'}
|
Perform the connection to the server.
|
def _diff(text_0, text_1):
diff = difflib.ndiff(text_0.splitlines(), text_1.splitlines())
return _diff_removed_lines(diff)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_diff'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text_0'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text_1'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'difflib'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ndiff'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '20']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'text_0'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'text_1'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_diff_removed_lines'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'diff'}
|
Return a diff between two strings.
|
def OnSearch(self, event):
search_string = self.search.GetValue()
if search_string not in self.search_history:
self.search_history.append(search_string)
if len(self.search_history) > 10:
self.search_history.pop(0)
self.menu = self.make_menu()
self.search.SetMenu(self.menu)
search_flags = self.search_options + ["FIND_NEXT"]
post_command_event(self, self.FindMsg, text=search_string,
flags=search_flags)
self.search.SetFocus()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'OnSearch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'event'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '33', '52', '62', '73', '82', '96']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'search_string'}; {'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': 'search'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'GetValue'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'not in'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'search_string'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'search_history'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'search_history'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'search_string'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '42']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '41'], 'value': '>'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'search_history'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'search_history'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'menu'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'make_menu'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'SetMenu'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'menu'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'search_flags'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '80'], 'value': '+'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'search_options'}; {'id': '80', 'type': 'list', 'children': ['81'], 'value': '["FIND_NEXT"]'}; {'id': '81', 'type': 'string', 'children': [], 'value': '"FIND_NEXT"'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'post_command_event'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87', '90', '93']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'FindMsg'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'search_string'}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'search_flags'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '103']}; {'id': '98', 'type': 'attribute', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'SetFocus'}; {'id': '103', 'type': 'argument_list', 'children': []}
|
Event handler for starting the search
|
def split_taf(txt: str) -> [str]:
lines = []
split = txt.split()
last_index = 0
for i, item in enumerate(split):
if starts_new_line(item) and i != 0 and not split[i - 1].startswith('PROB'):
lines.append(' '.join(split[last_index:i]))
last_index = i
lines.append(' '.join(split[last_index:]))
return lines
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_taf'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'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': 'type', 'children': ['9']}; {'id': '9', 'type': 'list', 'children': ['10'], 'value': '[str]'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '11', 'type': 'block', 'children': ['12', '16', '24', '28', '80', '96']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '15', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'txt'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'last_index'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'for_statement', 'children': ['29', '32', '36']}; {'id': '29', 'type': 'pattern_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '58']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '47'], 'value': 'and'}; {'id': '39', 'type': 'boolean_operator', 'children': ['40', '44'], 'value': 'and'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'starts_new_line'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': '!='}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'not_operator', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '56']}; {'id': '49', 'type': 'attribute', 'children': ['50', '55']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '-'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': "'PROB'"}; {'id': '58', 'type': 'block', 'children': ['59', '76']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '72', 'type': 'slice', 'children': ['73', '74', '75']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'last_index'}; {'id': '74', 'type': 'colon', 'children': []}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'last_index'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '93', 'type': 'slice', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'last_index'}; {'id': '95', 'type': 'colon', 'children': []}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'lines'}
|
Splits a TAF report into each distinct time period
|
def execute(self, array_id = None, machine_name = None):
self.status = 'executing'
if array_id is not None:
for array_job in self.array:
if array_job.id == array_id:
array_job.status = 'executing'
if machine_name is not None:
array_job.machine_name = machine_name
array_job.start_time = datetime.now()
elif machine_name is not None:
self.machine_name = machine_name
if self.start_time is None:
self.start_time = datetime.now()
for job in self.get_jobs_we_wait_for():
if job.array and job.status == 'executing':
job.finish(0, -1)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}; {'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': 'array_id'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'machine_name'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '18', '74', '91']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'executing'"}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22', '63']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'is not'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'array_id'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '28']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'array_job'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'if_statement', 'children': ['30', '35']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '34'], 'value': '=='}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'array_job'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'array_id'}; {'id': '35', 'type': 'block', 'children': ['36', '42']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'array_job'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'executing'"}; {'id': '42', 'type': 'if_statement', 'children': ['43', '46']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': 'is not'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'machine_name'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'block', 'children': ['47', '53']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'array_job'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'machine_name'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'machine_name'}; {'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': 'array_job'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'elif_clause', 'children': ['64', '67']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': 'is not'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'machine_name'}; {'id': '66', 'type': 'None', 'children': []}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'machine_name'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'machine_name'}; {'id': '74', 'type': 'if_statement', 'children': ['75', '80']}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '79'], 'value': 'is'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '79', 'type': 'None', 'children': []}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'start_time'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '90', 'type': 'argument_list', 'children': []}; {'id': '91', 'type': 'for_statement', 'children': ['92', '93', '98']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'get_jobs_we_wait_for'}; {'id': '97', 'type': 'argument_list', 'children': []}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'if_statement', 'children': ['100', '109']}; {'id': '100', 'type': 'boolean_operator', 'children': ['101', '104'], 'value': 'and'}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '108'], 'value': '=='}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '108', 'type': 'string', 'children': [], 'value': "'executing'"}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'finish'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '117']}; {'id': '116', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '117', 'type': 'unary_operator', 'children': ['118'], 'value': '-'}; {'id': '118', 'type': 'integer', 'children': [], 'value': '1'}
|
Sets the status of this job to 'executing'.
|
def check_coverage():
with lcd(settings.LOCAL_COVERAGE_PATH):
total_line = local('grep -n Total index.html', capture=True)
match = re.search(r'^(\d+):', total_line)
total_line_number = int(match.groups()[0])
percentage_line_number = total_line_number + 5
percentage_line = local(
'awk NR=={0} index.html'.format(percentage_line_number),
capture=True)
match = re.search(r'(\d.+)%', percentage_line)
try:
percentage = float(match.groups()[0])
except ValueError:
match = re.search(r'(\d+)%', percentage_line)
percentage = float(match.groups()[0])
if percentage < 100:
abort(red('Coverage is {0}%'.format(percentage)))
print(green('Coverage is {0}%'.format(percentage)))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_coverage'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '120', '138']}; {'id': '5', 'type': 'with_statement', 'children': ['6', '14']}; {'id': '6', 'type': 'with_clause', 'children': ['7']}; {'id': '7', 'type': 'with_item', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'lcd'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'LOCAL_COVERAGE_PATH'}; {'id': '14', 'type': 'block', 'children': ['15', '25', '35', '48', '54', '69', '79']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'total_line'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'grep -n Total index.html'"}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'capture'}; {'id': '24', 'type': 'True', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "r'^(\\d+):'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'total_line'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'total_line_number'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'subscript', 'children': ['42', '47']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'percentage_line_number'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '+'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'total_line_number'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'percentage_line'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '66']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'awk NR=={0} index.html'"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'percentage_line_number'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'capture'}; {'id': '68', 'type': 'True', 'children': []}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': "r'(\\d.+)%'"}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'percentage_line'}; {'id': '79', 'type': 'try_statement', 'children': ['80', '94']}; {'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': 'percentage'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'subscript', 'children': ['88', '93']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '92', 'type': 'argument_list', 'children': []}; {'id': '93', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '94', 'type': 'except_clause', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '96', 'type': 'block', 'children': ['97', '107']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106']}; {'id': '105', 'type': 'string', 'children': [], 'value': "r'(\\d+)%'"}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'percentage_line'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'percentage'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'subscript', 'children': ['114', '119']}; {'id': '114', 'type': 'call', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '118', 'type': 'argument_list', 'children': []}; {'id': '119', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '120', 'type': 'if_statement', 'children': ['121', '124']}; {'id': '121', 'type': 'comparison_operator', 'children': ['122', '123'], 'value': '<'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'percentage'}; {'id': '123', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'abort'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'red'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'string', 'children': [], 'value': "'Coverage is {0}%'"}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'percentage'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'call', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'green'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'string', 'children': [], 'value': "'Coverage is {0}%'"}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'percentage'}
|
Checks if the coverage is 100%.
|
def _get_image_numpy_dtype(self):
try:
ftype = self._info['img_equiv_type']
npy_type = _image_bitpix2npy[ftype]
except KeyError:
raise KeyError("unsupported fits data type: %d" % ftype)
return npy_type
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_image_numpy_dtype'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '32']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '22']}; {'id': '7', 'type': 'block', 'children': ['8', '16']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '11', 'type': 'subscript', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_info'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'img_equiv_type'"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'npy_type'}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_image_bitpix2npy'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '22', 'type': 'except_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'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': 'KeyError'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '31'], 'value': '%'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"unsupported fits data type: %d"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ftype'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'npy_type'}
|
Get the numpy dtype for the image
|
def stem(self):
name = self.name
i = name.rfind('.')
if 0 < i < len(name) - 1:
return name[:i]
else:
return name
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stem'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '21']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rfind'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '21', 'type': 'if_statement', 'children': ['22', '31', '38']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24', '25'], 'value': '<'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '25', 'type': 'binary_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': 'name'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '35', 'type': 'slice', 'children': ['36', '37']}; {'id': '36', 'type': 'colon', 'children': []}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'name'}
|
The final path component, minus its last suffix.
|
def wr_hdrs(self, worksheet, row_idx):
for col_idx, hdr in enumerate(self.hdrs):
worksheet.write(row_idx, col_idx, hdr, self.fmt_hdr)
row_idx += 1
return row_idx
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wr_hdrs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'worksheet'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'row_idx'}; {'id': '7', 'type': 'block', 'children': ['8', '31', '35']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '12', '18']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'col_idx'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'hdrs'}; {'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': 'worksheet'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '27', '28']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'row_idx'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'col_idx'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'fmt_hdr'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'augmented_assignment', 'children': ['33', '34'], 'value': '+='}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'row_idx'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'row_idx'}
|
Print row of column headers
|
def append(self, item):
if not isinstance(item, str):
raise TypeError(
'Members of this object must be strings. '
'You supplied \"%s\"' % type(item))
list.append(self, item)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'append'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '6', 'type': 'block', 'children': ['7', '27']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'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': 'item'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'raise_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '23'], 'value': '%'}; {'id': '20', 'type': 'concatenated_string', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'Members of this object must be strings. '"}; {'id': '22', 'type': 'string', 'children': [], 'value': '\'You supplied \\"%s\\"\''}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'item'}
|
Adds an item to the list and checks it's a string.
|
def ask_visualization():
printDebug(
"Please choose an output format for the ontology visualization: (q=quit)\n",
"important")
while True:
text = ""
for viz in VISUALIZATIONS_LIST:
text += "%d) %s\n" % (VISUALIZATIONS_LIST.index(viz) + 1,
viz['Title'])
var = input(text + ">")
if var == "q":
return ""
else:
try:
n = int(var) - 1
test = VISUALIZATIONS_LIST[
n]
return n
except:
printDebug("Invalid selection. Please try again.", "red")
continue
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ask_visualization'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'call', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'printDebug'}; {'id': '8', 'type': 'argument_list', 'children': ['9', '10']}; {'id': '9', 'type': 'string', 'children': [], 'value': '"Please choose an output format for the ontology visualization: (q=quit)\\n"'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"important"'}; {'id': '11', 'type': 'while_statement', 'children': ['12', '13']}; {'id': '12', 'type': 'True', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '18', '39', '48']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '17', 'type': 'string', 'children': [], 'value': '""'}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'viz'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'VISUALIZATIONS_LIST'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'augmented_assignment', 'children': ['24', '25'], 'value': '+='}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '%'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"%d) %s\\n"'}; {'id': '27', 'type': 'tuple', 'children': ['28', '36']}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '35'], 'value': '+'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'VISUALIZATIONS_LIST'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'viz'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'viz'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'Title'"}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'input'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '+'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '47', 'type': 'string', 'children': [], 'value': '">"'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '52', '55']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': '=='}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"q"'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'string', 'children': [], 'value': '""'}; {'id': '55', 'type': 'else_clause', 'children': ['56']}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'try_statement', 'children': ['58', '76']}; {'id': '58', 'type': 'block', 'children': ['59', '68', '74']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '67'], 'value': '-'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'VISUALIZATIONS_LIST'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '76', 'type': 'except_clause', 'children': ['77']}; {'id': '77', 'type': 'block', 'children': ['78', '84']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'printDebug'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': '"Invalid selection. Please try again."'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"red"'}; {'id': '84', 'type': 'continue_statement', 'children': []}
|
ask user which viz output to use
|
def force_bytes(value):
if IS_PY3:
if isinstance(value, str):
value = value.encode('utf-8', 'backslashreplace')
else:
if isinstance(value, unicode):
value = value.encode('utf-8')
return value
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'force_bytes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'block', 'children': ['6', '44']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '8', '26']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'IS_PY3'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '25', 'type': 'string', 'children': [], 'value': "'backslashreplace'"}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '34']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Forces a Unicode string to become a bytestring.
|
def stem(self, word):
if self.stemmer:
return unicode_to_ascii(self._stemmer.stem(word))
else:
return word
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stem'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11', '24']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'stemmer'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'unicode_to_ascii'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_stemmer'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'stem'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'word'}; {'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': 'word'}
|
Perform stemming on an input word.
|
def write_data(self, write_finished_cb):
self._write_finished_cb = write_finished_cb
data = bytearray()
for poly4D in self.poly4Ds:
data += struct.pack('<ffffffff', *poly4D.x.values)
data += struct.pack('<ffffffff', *poly4D.y.values)
data += struct.pack('<ffffffff', *poly4D.z.values)
data += struct.pack('<ffffffff', *poly4D.yaw.values)
data += struct.pack('<f', poly4D.duration)
self.mem_handler.write(self, 0x00, data, flush_queue=True)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'write_finished_cb'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '97']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_write_finished_cb'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'write_finished_cb'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'bytearray'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'for_statement', 'children': ['20', '21', '24']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'poly4D'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'poly4Ds'}; {'id': '24', 'type': 'block', 'children': ['25', '40', '55', '70', '85']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'augmented_assignment', 'children': ['27', '28'], 'value': '+='}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'<ffffffff'"}; {'id': '34', 'type': 'list_splat', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'poly4D'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'augmented_assignment', 'children': ['42', '43'], 'value': '+='}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'<ffffffff'"}; {'id': '49', 'type': 'list_splat', 'children': ['50']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'poly4D'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'augmented_assignment', 'children': ['57', '58'], 'value': '+='}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'<ffffffff'"}; {'id': '64', 'type': 'list_splat', 'children': ['65']}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'poly4D'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'augmented_assignment', 'children': ['72', '73'], 'value': '+='}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'string', 'children': [], 'value': "'<ffffffff'"}; {'id': '79', 'type': 'list_splat', 'children': ['80']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'poly4D'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'yaw'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'augmented_assignment', 'children': ['87', '88'], 'value': '+='}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94']}; {'id': '93', 'type': 'string', 'children': [], 'value': "'<f'"}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'poly4D'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'duration'}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '104']}; {'id': '99', 'type': 'attribute', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'mem_handler'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '104', 'type': 'argument_list', 'children': ['105', '106', '107', '108']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '0x00'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'flush_queue'}; {'id': '110', 'type': 'True', 'children': []}
|
Write trajectory data to the Crazyflie
|
def todo(self):
if not os.path.exists(self.migrate_dir):
self.logger.warn('Migration directory: %s does not exist.', self.migrate_dir)
os.makedirs(self.migrate_dir)
return sorted(f[:-3] for f in os.listdir(self.migrate_dir) if self.filemask.match(f))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'todo'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '40']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '18']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'migrate_dir'}; {'id': '18', 'type': 'block', 'children': ['19', '31']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'Migration directory: %s does not exist.'"}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'migrate_dir'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'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': 'migrate_dir'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '43', 'type': 'generator_expression', 'children': ['44', '50', '60']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '46', 'type': 'slice', 'children': ['47', '48']}; {'id': '47', 'type': 'colon', 'children': []}; {'id': '48', 'type': 'unary_operator', 'children': ['49'], 'value': '-'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '50', 'type': 'for_in_clause', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'listdir'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'migrate_dir'}; {'id': '60', 'type': 'if_clause', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'filemask'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'f'}
|
Scan migrations in file system.
|
def limits(self,variable):
(vmin,vmax), = self.SELECT('min(%(variable)s), max(%(variable)s)' % vars())
return vmin,vmax
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'limits'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '6', 'type': 'block', 'children': ['7', '23']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '13']}; {'id': '9', 'type': 'pattern_list', 'children': ['10']}; {'id': '10', 'type': 'tuple_pattern', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'vmin'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'vmax'}; {'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': 'SELECT'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '20'], 'value': '%'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'min(%(variable)s), max(%(variable)s)'"}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'expression_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'vmin'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'vmax'}
|
Return minimum and maximum of variable across all rows of data.
|
def column_correlations(self, X):
utils.validation.check_is_fitted(self, 's_')
if isinstance(X, np.ndarray):
X = pd.DataFrame(X)
row_pc = self.row_coordinates(X)
return pd.DataFrame({
component: {
feature: row_pc[component].corr(X[feature])
for feature in X.columns
}
for component in row_pc.columns
})
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'column_correlations'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '35', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'validation'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'check_is_fitted'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'s_'"}; {'id': '17', 'type': 'if_statement', 'children': ['18', '25']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pd'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'DataFrame'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'row_pc'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'row_coordinates'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'pd'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'DataFrame'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'dictionary_comprehension', 'children': ['51', '71']}; {'id': '51', 'type': 'pair', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '53', 'type': 'dictionary_comprehension', 'children': ['54', '66']}; {'id': '54', 'type': 'pair', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '56', 'type': 'call', 'children': ['57', '62']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'row_pc'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'corr'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '66', 'type': 'for_in_clause', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '71', 'type': 'for_in_clause', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'row_pc'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'columns'}
|
Returns the column correlations with each principal component.
|
def step_type(self):
if 'stepfc' in self.__class__.__name__.lower():
return STEP_FC
if 'stepkw' in self.__class__.__name__.lower():
return STEP_KW
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'step_type'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '18']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9'], 'value': 'in'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'stepfc'"}; {'id': '9', 'type': 'call', 'children': ['10', '17']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'STEP_FC'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '33']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': 'in'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'stepkw'"}; {'id': '24', 'type': 'call', 'children': ['25', '32']}; {'id': '25', 'type': 'attribute', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'STEP_KW'}
|
Whether it's a IFCW step or Keyword Wizard Step.
|
def print_plugins(self):
width = console_width()
line = Style.BRIGHT + '=' * width + '\n'
middle = int(width / 2)
if self.available_providers:
print(line + ' ' * middle + 'PROVIDERS')
for provider in sorted(self.available_providers.values(),
key=lambda x: x.identifier):
provider().print()
print()
if self.available_checkers:
print(line + ' ' * middle + 'CHECKERS')
for checker in sorted(self.available_checkers.values(),
key=lambda x: x.identifier):
checker().print()
print()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_plugins'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '24', '33', '82']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'console_width'}; {'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': 'line'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '23'], 'value': '+'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '20'], 'value': '+'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Style'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'BRIGHT'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '*'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'middle'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '32'], 'value': '/'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'available_providers'}; {'id': '37', 'type': 'block', 'children': ['38', '49']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '48'], 'value': '+'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '+'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '*'}; {'id': '46', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'middle'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'PROVIDERS'"}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '69']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '61']}; {'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': 'available_providers'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '60', 'type': 'argument_list', 'children': []}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '63', 'type': 'lambda', 'children': ['64', '66']}; {'id': '64', 'type': 'lambda_parameters', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '69', 'type': 'block', 'children': ['70', '78']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'provider'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'if_statement', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'available_checkers'}; {'id': '86', 'type': 'block', 'children': ['87', '98']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '97'], 'value': '+'}; {'id': '92', 'type': 'binary_operator', 'children': ['93', '94'], 'value': '+'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '96'], 'value': '*'}; {'id': '95', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'middle'}; {'id': '97', 'type': 'string', 'children': [], 'value': "'CHECKERS'"}; {'id': '98', 'type': 'for_statement', 'children': ['99', '100', '118']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'checker'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '110']}; {'id': '103', 'type': 'call', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'available_checkers'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '109', 'type': 'argument_list', 'children': []}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '112', 'type': 'lambda', 'children': ['113', '115']}; {'id': '113', 'type': 'lambda_parameters', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '118', 'type': 'block', 'children': ['119', '127']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '126']}; {'id': '121', 'type': 'attribute', 'children': ['122', '125']}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'checker'}; {'id': '124', 'type': 'argument_list', 'children': []}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '126', 'type': 'argument_list', 'children': []}; {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'call', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '130', 'type': 'argument_list', 'children': []}
|
Print the available plugins.
|
def _from_api_repr(cls, resource):
job_id = resource.get("jobId")
project = resource.get("projectId")
location = resource.get("location")
job_ref = cls(job_id, project, location)
return job_ref
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_api_repr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '34', '43']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'job_id'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"jobId"'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"projectId"'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"location"'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'job_ref'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'job_id'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'job_ref'}
|
Returns a job reference for an API resource representation.
|
def blacklistClient(self, clientName: str,
reason: str = None, code: int = None):
msg = "{} blacklisting client {}".format(self, clientName)
if reason:
msg += " for reason {}".format(reason)
logger.display(msg)
self.clientBlacklister.blacklist(clientName)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'blacklistClient'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'clientName'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'typed_default_parameter', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'typed_default_parameter', 'children': ['15', '16', '18']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20', '30', '42', '49']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"{} blacklisting client {}"'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'clientName'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'augmented_assignment', 'children': ['35', '36'], 'value': '+='}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '" for reason {}"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'clientBlacklister'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'blacklist'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'clientName'}
|
Add the client specified by `clientName` to this node's blacklist
|
def wc_names(self):
if self.wc_name is None:
res = set()
else:
res = set([self.wc_name])
if self.args is not None:
for arg in self.args:
if isinstance(arg, Pattern):
res.update(arg.wc_names)
if self.kwargs is not None:
for val in self.kwargs.values():
if isinstance(val, Pattern):
res.update(val.wc_names)
return res
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wc_names'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '31', '60', '93']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12', '19']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'wc_name'}; {'id': '11', 'type': 'None', 'children': []}; {'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': 'res'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'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': 'res'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'list', 'children': ['28'], 'value': '[self.wc_name]'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'wc_name'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '36'], 'value': 'is not'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'for_statement', 'children': ['39', '40', '43']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'if_statement', 'children': ['45', '50']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Pattern'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'wc_names'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '66']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '65'], 'value': 'is not'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'for_statement', 'children': ['68', '69', '76']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'val'}; {'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': 'kwargs'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'if_statement', 'children': ['78', '83']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'Pattern'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'wc_names'}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'res'}
|
Set of all wildcard names occurring in the pattern
|
def add(self, r):
id = r.get_residue_id()
if self.order:
last_id = self.order[-1]
if id in self.order:
raise colortext.Exception('Warning: using code to "allow for multiresidue noncanonicals" - check this case manually.')
id = '%s.%d'%(str(id),self.special_insertion_count)
self.special_insertion_count += 1
assert(r.Chain == self.sequence[last_id].Chain)
assert(r.residue_type == self.sequence[last_id].residue_type)
self.order.append(id)
self.sequence[id] = r
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '88', '97']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_residue_id'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '19', 'type': 'block', 'children': ['20', '29', '62', '75']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'last_id'}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '27', 'type': 'unary_operator', 'children': ['28'], 'value': '-'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '35']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'in'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '35', 'type': 'block', 'children': ['36', '43', '56']}; {'id': '36', 'type': 'raise_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'colortext'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': '\'Warning: using code to "allow for multiresidue noncanonicals" - check this case manually.\''}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '%'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'%s.%d'"}; {'id': '48', 'type': 'tuple', 'children': ['49', '53']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'special_insertion_count'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'augmented_assignment', 'children': ['58', '61'], 'value': '+='}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'special_insertion_count'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'assert_statement', 'children': ['63']}; {'id': '63', 'type': '()', 'children': ['64']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '68'], 'value': '=='}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'Chain'}; {'id': '68', 'type': 'attribute', 'children': ['69', '74']}; {'id': '69', 'type': 'subscript', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'last_id'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'Chain'}; {'id': '75', 'type': 'assert_statement', 'children': ['76']}; {'id': '76', 'type': '()', 'children': ['77']}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '81'], 'value': '=='}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'residue_type'}; {'id': '81', 'type': 'attribute', 'children': ['82', '87']}; {'id': '82', 'type': 'subscript', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'last_id'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'residue_type'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '95']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '104']}; {'id': '99', 'type': 'subscript', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'sequence'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'r'}
|
Takes an id and a Residue r and adds them to the Sequence.
|
def data_import(self, json_response):
if 'data' not in json_response:
raise PyVLXException('no element data found: {0}'.format(
json.dumps(json_response)))
data = json_response['data']
for item in data:
self.load_scene(item)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_import'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'json_response'}; {'id': '6', 'type': 'block', 'children': ['7', '27', '33']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'not in'}; {'id': '9', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'json_response'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'raise_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'PyVLXException'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'no element data found: {0}'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'json_response'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'json_response'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data'}; {'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': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'load_scene'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'item'}
|
Import scenes from JSON response.
|
def authenticate(self, username=None, password=None, **kwargs):
try:
user = User.objects.get(email=username)
if user.check_password(password):
return user
except (User.DoesNotExist, User.MultipleObjectsReturned):
logging.warning('Unsuccessful login attempt using username/email: {0}'.format(username))
return None
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authenticate'}; {'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': 'username'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '13', 'type': 'block', 'children': ['14', '60']}; {'id': '14', 'type': 'try_statement', 'children': ['15', '39']}; {'id': '15', 'type': 'block', 'children': ['16', '29']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'user'}; {'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': 'User'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '36']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'check_password'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '39', 'type': 'except_clause', 'children': ['40', '47']}; {'id': '40', 'type': 'tuple', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'DoesNotExist'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'User'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'MultipleObjectsReturned'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'Unsuccessful login attempt using username/email: {0}'"}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'None', 'children': []}
|
"username" being passed is really email address and being compared to as such.
|
def add_source(self, url, *, note=''):
new = {'url': url, 'note': note}
self.sources.append(new)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'keyword_separator', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '9', 'type': 'string', 'children': [], 'value': "''"}; {'id': '10', 'type': 'block', 'children': ['11', '21']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '14', 'type': 'dictionary', 'children': ['15', '18']}; {'id': '15', 'type': 'pair', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'url'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'note'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sources'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'new'}
|
Add a source URL from which data was collected
|
def limit_author_choices():
LIMIT_AUTHOR_CHOICES = getattr(settings, 'BLOG_LIMIT_AUTHOR_CHOICES_GROUP', None)
if LIMIT_AUTHOR_CHOICES:
if isinstance(LIMIT_AUTHOR_CHOICES, str):
limit = Q(groups__name=LIMIT_AUTHOR_CHOICES)
else:
limit = Q()
for s in LIMIT_AUTHOR_CHOICES:
limit = limit | Q(groups__name=s)
if getattr(settings, 'BLOG_LIMIT_AUTHOR_CHOICES_ADMIN', False):
limit = limit | Q(is_staff=True)
else:
limit = {'is_staff': True}
return limit
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'limit_author_choices'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '84']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'LIMIT_AUTHOR_CHOICES'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'BLOG_LIMIT_AUTHOR_CHOICES_GROUP'"}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '16', '75']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'LIMIT_AUTHOR_CHOICES'}; {'id': '16', 'type': 'block', 'children': ['17', '56']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23', '33']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'LIMIT_AUTHOR_CHOICES'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'groups__name'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'LIMIT_AUTHOR_CHOICES'}; {'id': '33', 'type': 'else_clause', 'children': ['34']}; {'id': '34', 'type': 'block', 'children': ['35', '41']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'for_statement', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'LIMIT_AUTHOR_CHOICES'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '|'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'groups__name'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '63']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'BLOG_LIMIT_AUTHOR_CHOICES_ADMIN'"}; {'id': '62', 'type': 'False', 'children': []}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '69'], 'value': '|'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'is_staff'}; {'id': '74', 'type': 'True', 'children': []}; {'id': '75', 'type': 'else_clause', 'children': ['76']}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '80', 'type': 'dictionary', 'children': ['81']}; {'id': '81', 'type': 'pair', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': "'is_staff'"}; {'id': '83', 'type': 'True', 'children': []}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'limit'}
|
Limit choices in blog author field based on config settings
|
def calculate_leapdays(init_date, final_date):
leap_days = (final_date.year - 1) // 4 - (init_date.year - 1) // 4
leap_days -= (final_date.year - 1) // 100 - (init_date.year - 1) // 100
leap_days += (final_date.year - 1) // 400 - (init_date.year - 1) // 400
return datetime.timedelta(days=leap_days)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_leapdays'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'init_date'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'final_date'}; {'id': '6', 'type': 'block', 'children': ['7', '27', '47', '67']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'leap_days'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '19'], 'value': '-'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '18'], 'value': '//'}; {'id': '12', 'type': '()', 'children': ['13']}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '17'], 'value': '-'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'final_date'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '26'], 'value': '//'}; {'id': '20', 'type': '()', 'children': ['21']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '25'], 'value': '-'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'init_date'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'augmented_assignment', 'children': ['29', '30'], 'value': '-='}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'leap_days'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '39'], 'value': '-'}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '38'], 'value': '//'}; {'id': '32', 'type': '()', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '37'], 'value': '-'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'final_date'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '46'], 'value': '//'}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '45'], 'value': '-'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'init_date'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'augmented_assignment', 'children': ['49', '50'], 'value': '+='}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'leap_days'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '59'], 'value': '-'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '58'], 'value': '//'}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '57'], 'value': '-'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'final_date'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '400'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '66'], 'value': '//'}; {'id': '60', 'type': '()', 'children': ['61']}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '65'], 'value': '-'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'init_date'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '400'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'leap_days'}
|
Currently unsupported, it only works for differences in years.
|
def _ParseMatchGrp(self, key, val):
if key in self._match_keywords:
self._ParseEntry(key, val)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ParseMatchGrp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'in'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_match_keywords'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_ParseEntry'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'val'}
|
Adds valid match group parameters to the configuration.
|
def existing_path(value):
if os.path.exists(value):
return value
else:
raise argparse.ArgumentTypeError("Path {0} not found".format(value))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'existing_path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '15', '18']}; {'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': 'exists'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '18', 'type': 'else_clause', 'children': ['19']}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'raise_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'argparse'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ArgumentTypeError'}; {'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': '"Path {0} not found"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Throws when the path does not exist
|
def load_json(self, json):
for key in json:
if key == "wandb_version":
continue
self._items[key] = json[key].get('value')
self._descriptions[key] = json[key].get('desc')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_json'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '10']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '10', 'type': 'block', 'children': ['11', '17', '32']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': '=='}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"wandb_version"'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'continue_statement', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '24']}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_items'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '39']}; {'id': '34', 'type': 'subscript', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_descriptions'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'desc'"}
|
Loads existing config from JSON
|
def t_ID(self, t):
r'[a-zA-Z_@][a-zA-Z0-9_@\-]*'
t.type = self.reserved_words.get(t.value, 'ID')
return t
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 't_ID'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': "r'[a-zA-Z_@][a-zA-Z0-9_@\\-]*'"}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'type'}; {'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': 'reserved_words'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'ID'"}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 't'}
|
r'[a-zA-Z_@][a-zA-Z0-9_@\-]*
|
def render_toctrees(kb_app: kb, sphinx_app: Sphinx, doctree: doctree,
fromdocname: str):
settings: KaybeeSettings = sphinx_app.config.kaybee_settings
if not settings.articles.use_toctree:
return
builder: StandaloneHTMLBuilder = sphinx_app.builder
env: BuildEnvironment = sphinx_app.env
registered_toctree = ToctreeAction.get_for_context(kb_app)
for node in doctree.traverse(toctree):
if node.attributes['hidden']:
continue
custom_toctree = registered_toctree(fromdocname)
context = builder.globalcontext.copy()
context['sphinx_app'] = sphinx_app
entries = node.attributes['entries']
custom_toctree.set_entries(entries, env.titles,
sphinx_app.env.resources)
output = custom_toctree.render(builder, context, sphinx_app)
listing = [nodes.raw('', output, format='html')]
node.replace_self(listing)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_toctrees'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12', '16']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'kb_app'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kb'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Sphinx'}; {'id': '12', 'type': 'typed_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'doctree'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'doctree'}; {'id': '16', 'type': 'typed_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fromdocname'}; {'id': '18', 'type': 'type', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'block', 'children': ['21', '31', '40', '48', '56', '65']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24', '26']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '24', 'type': 'type', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'KaybeeSettings'}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'kaybee_settings'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '38']}; {'id': '32', 'type': 'not_operator', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'articles'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'use_toctree'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'return_statement', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43', '45']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '43', 'type': 'type', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'StandaloneHTMLBuilder'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51', '53']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '51', 'type': 'type', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'BuildEnvironment'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'registered_toctree'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'ToctreeAction'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'get_for_context'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'kb_app'}; {'id': '65', 'type': 'for_statement', 'children': ['66', '67', '73']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'doctree'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'traverse'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'toctree'}; {'id': '73', 'type': 'block', 'children': ['74', '82', '89', '99', '105', '113', '128', '139', '153']}; {'id': '74', 'type': 'if_statement', 'children': ['75', '80']}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'hidden'"}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'continue_statement', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'custom_toctree'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'registered_toctree'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'fromdocname'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '92', 'type': 'call', 'children': ['93', '98']}; {'id': '93', 'type': 'attribute', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'globalcontext'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '98', 'type': 'argument_list', 'children': []}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '104']}; {'id': '101', 'type': 'subscript', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '103', 'type': 'string', 'children': [], 'value': "'sphinx_app'"}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'entries'}; {'id': '108', 'type': 'subscript', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '112', 'type': 'string', 'children': [], 'value': "'entries'"}; {'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': 'custom_toctree'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'set_entries'}; {'id': '118', 'type': 'argument_list', 'children': ['119', '120', '123']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'entries'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'titles'}; {'id': '123', 'type': 'attribute', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '128', 'type': 'expression_statement', 'children': ['129']}; {'id': '129', 'type': 'assignment', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '131', 'type': 'call', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'custom_toctree'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '135', 'type': 'argument_list', 'children': ['136', '137', '138']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'builder'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'sphinx_app'}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'listing'}; {'id': '142', 'type': 'list', 'children': ['143'], 'value': "[nodes.raw('', output, format='html')]"}; {'id': '143', 'type': 'call', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'raw'}; {'id': '147', 'type': 'argument_list', 'children': ['148', '149', '150']}; {'id': '148', 'type': 'string', 'children': [], 'value': "''"}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '150', 'type': 'keyword_argument', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '152', 'type': 'string', 'children': [], 'value': "'html'"}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'replace_self'}; {'id': '158', 'type': 'argument_list', 'children': ['159']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'listing'}
|
Look in doctrees for toctree and replace with custom render
|
def sort(ctx):
head = ctx.parent.head
vcf_handle = ctx.parent.handle
outfile = ctx.parent.outfile
silent = ctx.parent.silent
print_headers(head, outfile=outfile, silent=silent)
for line in sort_variants(vcf_handle):
print_variant(variant_line=line, outfile=outfile, silent=silent)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '22', '30', '38', '49']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'vcf_handle'}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'silent'}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'silent'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'print_headers'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43', '46']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'silent'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'silent'}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '55']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'sort_variants'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'vcf_handle'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'print_variant'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63', '66']}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'variant_line'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'outfile'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'silent'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'silent'}
|
Sort the variants of a vcf file
|
def cmd_list_identities(self, *args):
identities = self._get_available_identities()
print('Available identities:')
for x in identities:
print(' - {}'.format(x))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd_list_identities'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '21']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'identities'}; {'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': '_get_available_identities'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'Available identities:'"}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'identities'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "' - {}'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'x'}
|
List the available identities to use for signing.
|
def to_native_units(self, motor):
assert abs(self.degrees_per_second) <= motor.max_dps,\
"invalid degrees-per-second: {} max DPS is {}, {} was requested".format(
motor, motor.max_dps, self.degrees_per_second)
return self.degrees_per_second/motor.max_dps * motor.max_speed
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_native_units'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'motor'}; {'id': '6', 'type': 'block', 'children': ['7', '30']}; {'id': '7', 'type': 'assert_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '15'], 'value': '<='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'degrees_per_second'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'motor'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'max_dps'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"invalid degrees-per-second: {} max DPS is {}, {} was requested"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '27']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'motor'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'motor'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'max_dps'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'degrees_per_second'}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '39'], 'value': '*'}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '36'], 'value': '/'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'degrees_per_second'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'motor'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'max_dps'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'motor'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'max_speed'}
|
Return the native speed measurement required to achieve desired degrees-per-second
|
def integrate(arr, ddim, dim=False, is_pressure=False):
if is_pressure:
dim = vert_coord_name(ddim)
return (arr*ddim).sum(dim=dim)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'integrate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ddim'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'is_pressure'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '23']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'is_pressure'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'vert_coord_name'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ddim'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '31']}; {'id': '25', 'type': 'attribute', 'children': ['26', '30']}; {'id': '26', 'type': '()', 'children': ['27']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '*'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ddim'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dim'}
|
Integrate along the given dimension.
|
def make_wsgi_app(registry=REGISTRY):
def prometheus_app(environ, start_response):
params = parse_qs(environ.get('QUERY_STRING', ''))
r = registry
encoder, content_type = choose_encoder(environ.get('HTTP_ACCEPT'))
if 'name[]' in params:
r = r.restricted_registry(params['name[]'])
output = encoder(r)
status = str('200 OK')
headers = [(str('Content-type'), content_type)]
start_response(status, headers)
return [output]
return prometheus_app
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_wsgi_app'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'REGISTRY'}; {'id': '7', 'type': 'block', 'children': ['8', '94']}; {'id': '8', 'type': 'function_definition', 'children': ['9', '10', '13']}; {'id': '9', 'type': 'function_name', 'children': [], 'value': 'prometheus_app'}; {'id': '10', 'type': 'parameters', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'start_response'}; {'id': '13', 'type': 'block', 'children': ['14', '27', '31', '45', '61', '68', '75', '85', '91']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parse_qs'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'QUERY_STRING'"}; {'id': '26', 'type': 'string', 'children': [], 'value': "''"}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'pattern_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'encoder'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'choose_encoder'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'HTTP_ACCEPT'"}; {'id': '45', 'type': 'if_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'in'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'name[]'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'restricted_registry'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'name[]'"}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'encoder'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'string', 'children': [], 'value': "'200 OK'"}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '78', 'type': 'list', 'children': ['79'], 'value': "[(str('Content-type'), content_type)]"}; {'id': '79', 'type': 'tuple', 'children': ['80', '84']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'string', 'children': [], 'value': "'Content-type'"}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'start_response'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'list', 'children': ['93'], 'value': '[output]'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'prometheus_app'}
|
Create a WSGI app which serves the metrics from a registry.
|
def create_alarm(panel_json, abode, area='1'):
panel_json['name'] = CONST.ALARM_NAME
panel_json['id'] = CONST.ALARM_DEVICE_ID + area
panel_json['type'] = CONST.ALARM_TYPE
panel_json['type_tag'] = CONST.DEVICE_ALARM
panel_json['generic_type'] = CONST.TYPE_ALARM
return AbodeAlarm(panel_json, abode, area)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_alarm'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'panel_json'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'abode'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'area'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'1'"}; {'id': '9', 'type': 'block', 'children': ['10', '18', '28', '36', '44', '52']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '15']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'panel_json'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'CONST'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ALARM_NAME'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'panel_json'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '27'], 'value': '+'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'CONST'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ALARM_DEVICE_ID'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'area'}; {'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': 'panel_json'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'CONST'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ALARM_TYPE'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'panel_json'}; {'id': '40', 'type': 'string', 'children': [], 'value': "'type_tag'"}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'CONST'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'DEVICE_ALARM'}; {'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': 'panel_json'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'generic_type'"}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'CONST'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'TYPE_ALARM'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'AbodeAlarm'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57', '58']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'panel_json'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'abode'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'area'}
|
Create a new alarm device from a panel response.
|
def _get_handler(self, node_id):
handler = self._get_attrs(node_id).get(self.HANDLER, self._default_handler)
if not isinstance(handler, BasicNodeHandler):
idaapi.msg(("Invalid handler for node {}: {}. All handlers must inherit from"
"`BasicNodeHandler`.").format(node_id, handler))
handler = self._default_handler
return handler
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_handler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'node_id'}; {'id': '6', 'type': 'block', 'children': ['7', '26', '56']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '10', 'type': 'call', 'children': ['11', '19']}; {'id': '11', 'type': 'attribute', 'children': ['12', '18']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_get_attrs'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'node_id'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'HANDLER'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_default_handler'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '33']}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'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': 'handler'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'BasicNodeHandler'}; {'id': '33', 'type': 'block', 'children': ['34', '50']}; {'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': 'idaapi'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '47']}; {'id': '41', 'type': 'attribute', 'children': ['42', '46']}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'concatenated_string', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"Invalid handler for node {}: {}. All handlers must inherit from"'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"`BasicNodeHandler`."'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'node_id'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'handler'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_default_handler'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'handler'}
|
Get the handler of a given node.
|
def splice(self, mark, newdata):
self.jump_to(mark)
self._data = self._data[:self._offset] + bytearray(newdata)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'splice'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mark'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'newdata'}; {'id': '7', 'type': 'block', 'children': ['8', '15']}; {'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': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'jump_to'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'mark'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_data'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '30'], 'value': '+'}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_data'}; {'id': '25', 'type': 'slice', 'children': ['26', '27']}; {'id': '26', 'type': 'colon', 'children': []}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_offset'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'bytearray'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'newdata'}
|
Replace the data after the marked location with the specified data.
|
def format_load_balancer_configuration(result):
from collections import OrderedDict
order_dict = OrderedDict()
if result.private_ip_address is not None:
order_dict['privateIpAddress'] = format_private_ip_address(result.private_ip_address)
if result.public_ip_address_resource_id is not None:
order_dict['publicIpAddressResourceId'] = result.public_ip_address_resource_id
if result.load_balancer_resource_id is not None:
order_dict['loadBalancerResourceId'] = result.load_balancer_resource_id
if result.probe_port is not None:
order_dict['probePort'] = result.probe_port
if result.sql_virtual_machine_instances is not None:
order_dict['sqlVirtualMachineInstances'] = result.sql_virtual_machine_instances
return order_dict
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_load_balancer_configuration'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '17', '35', '50', '65', '80', '95']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'collections'}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'order_dict'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': 'is not'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'private_ip_address'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'order_dict'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'privateIpAddress'"}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'format_private_ip_address'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'private_ip_address'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '41']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '40'], 'value': 'is not'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'public_ip_address_resource_id'}; {'id': '40', 'type': 'None', 'children': []}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'order_dict'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'publicIpAddressResourceId'"}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'public_ip_address_resource_id'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '56']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': 'is not'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'load_balancer_resource_id'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '62']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'order_dict'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'loadBalancerResourceId'"}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'load_balancer_resource_id'}; {'id': '65', 'type': 'if_statement', 'children': ['66', '71']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '70'], 'value': 'is not'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'probe_port'}; {'id': '70', 'type': 'None', 'children': []}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'order_dict'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'probePort'"}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'probe_port'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '86']}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '85'], 'value': 'is not'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'sql_virtual_machine_instances'}; {'id': '85', 'type': 'None', 'children': []}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '92']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'order_dict'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'sqlVirtualMachineInstances'"}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'sql_virtual_machine_instances'}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'order_dict'}
|
Formats the LoadBalancerConfiguration object removing arguments that are empty
|
def create_local_module_dir(cache_dir, module_name):
tf_v1.gfile.MakeDirs(cache_dir)
return os.path.join(cache_dir, module_name)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_local_module_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cache_dir'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'module_name'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tf_v1'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'gfile'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'MakeDirs'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cache_dir'}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cache_dir'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'module_name'}
|
Creates and returns the name of directory where to cache a module.
|
def include_original(dec):
def meta_decorator(method):
decorator = dec(method)
decorator._original = method
return decorator
return meta_decorator
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'include_original'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dec'}; {'id': '5', 'type': 'block', 'children': ['6', '26']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '10']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'meta_decorator'}; {'id': '8', 'type': 'parameters', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '10', 'type': 'block', 'children': ['11', '18', '24']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'decorator'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dec'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'decorator'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_original'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'decorator'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'meta_decorator'}
|
Decorate decorators so they include a copy of the original function.
|
def _linkToParent(self, feature, parentName):
parentParts = self.byFeatureName.get(parentName)
if parentParts is None:
raise GFF3Exception(
"Parent feature does not exist: {}".format(parentName),
self.fileName)
for parentPart in parentParts:
feature.parents.add(parentPart)
parentPart.children.add(feature)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_linkToParent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'parentName'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '37']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'parentParts'}; {'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': 'byFeatureName'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parentName'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'is'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'parentParts'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'raise_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'GFF3Exception'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '34']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"Parent feature does not exist: {}"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'parentName'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'fileName'}; {'id': '37', 'type': 'for_statement', 'children': ['38', '39', '40']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'parentPart'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'parentParts'}; {'id': '40', 'type': 'block', 'children': ['41', '50']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'feature'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'parentPart'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'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': 'parentPart'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'feature'}
|
Link a feature with its children
|
def columns(self):
fields = [f.label for f in self.form_fields
if self.cleaned_data["field_%s_export" % f.id]]
if self.cleaned_data["field_0_export"]:
fields.append(self.entry_time_name)
return fields
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'columns'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '28', '44']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '13', '18']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '13', 'type': 'for_in_clause', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'form_fields'}; {'id': '18', 'type': 'if_clause', 'children': ['19']}; {'id': '19', 'type': 'subscript', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cleaned_data'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '%'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"field_%s_export"'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '34']}; {'id': '29', 'type': 'subscript', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cleaned_data'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"field_0_export"'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'entry_time_name'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fields'}
|
Returns the list of selected column names.
|
def verify(backup_path, fast):
from PyHardLinkBackup.phlb.verify import verify_backup
verify_backup(backup_path, fast)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'backup_path'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fast'}; {'id': '6', 'type': 'block', 'children': ['7', '14']}; {'id': '7', 'type': 'import_from_statement', 'children': ['8', '12']}; {'id': '8', 'type': 'dotted_name', 'children': ['9', '10', '11']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'PyHardLinkBackup'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'phlb'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'verify'}; {'id': '12', 'type': 'dotted_name', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'verify_backup'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'verify_backup'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'backup_path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fast'}
|
Verify a existing backup
|
def _post(self, url, attributes=None, **kwargs):
return self._request('post', url, attributes, **kwargs)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_post'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'dictionary_splat_pattern', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_request'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '20', '21']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'post'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '21', 'type': 'dictionary_splat', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
|
Wrapper for the HTTP POST request.
|
def logs(self):
url = self._url + "/logs"
return _log(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '13'], 'value': '+'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"/logs"'}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_log'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21', '26', '31']}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}
|
returns the portals log information
|
def create_ambiente(self):
return Ambiente(
self.networkapi_url,
self.user,
self.password,
self.user_ldap)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_ambiente'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Ambiente'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '13', '16', '19']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'networkapi_url'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'user_ldap'}
|
Get an instance of ambiente services facade.
|
def update_view_count_by_uid(uid):
entry = TabWiki.update(
view_count=TabWiki.view_count + 1
).where(
TabWiki.uid == uid
)
entry.execute()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_view_count_by_uid'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '5', 'type': 'block', 'children': ['6', '30']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '9', 'type': 'call', 'children': ['10', '24']}; {'id': '10', 'type': 'attribute', 'children': ['11', '23']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'TabWiki'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'view_count'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '+'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'TabWiki'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'view_count'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '29'], 'value': '=='}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'TabWiki'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'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': 'entry'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '35', 'type': 'argument_list', 'children': []}
|
update the count of wiki, by uid.
|
def compare_urls(self, url1, url2):
return (self.normalize_url(url1) == self.normalize_url(url2))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compare_urls'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'url1'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'url2'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': '()', 'children': ['10']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '17'], 'value': '=='}; {'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': 'normalize_url'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'url1'}; {'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': 'normalize_url'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'url2'}
|
Compare two repo URLs for identity, ignoring incidental differences.
|
def spammer_view(request):
context = RequestContext(request, {})
template = Template("")
response = HttpResponse(template.render(context))
response.set_cookie(COOKIE_KEY, value=COOKIE_SPAM, httponly=True,
expires=datetime.now()+timedelta(days=3650))
if DJANGOSPAM_LOG:
log("BLOCK RESPONSE", request.method, request.path_info,
request.META.get("HTTP_USER_AGENT", "undefined"))
return response
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spammer_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '21', '33', '60', '83']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'RequestContext'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'request'}; {'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': 'template'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Template'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': '""'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'HttpResponse'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'context'}; {'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': 'response'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'set_cookie'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40', '43', '46']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'COOKIE_KEY'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'COOKIE_SPAM'}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'httponly'}; {'id': '45', 'type': 'True', 'children': []}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'expires'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '54'], 'value': '+'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '3650'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'DJANGOSPAM_LOG'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68', '71', '74']}; {'id': '67', 'type': 'string', 'children': [], 'value': '"BLOCK RESPONSE"'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'path_info'}; {'id': '74', 'type': 'call', 'children': ['75', '80']}; {'id': '75', 'type': 'attribute', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'META'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': '"HTTP_USER_AGENT"'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"undefined"'}; {'id': '83', 'type': 'return_statement', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'response'}
|
View for setting cookies on spammers.
|
def calculate_manual_reading(basic_data: BasicMeterData) -> Reading:
t_start = basic_data.previous_register_read_datetime
t_end = basic_data.current_register_read_datetime
read_start = basic_data.previous_register_read
read_end = basic_data.current_register_read
value = basic_data.quantity
uom = basic_data.uom
quality_method = basic_data.current_quality_method
return Reading(t_start, t_end, value, uom, quality_method, "", "",
read_start, read_end)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calculate_manual_reading'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'BasicMeterData'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Reading'}; {'id': '10', 'type': 'block', 'children': ['11', '17', '23', '29', '35', '41', '47', '53']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 't_start'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'previous_register_read_datetime'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 't_end'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'current_register_read_datetime'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'read_start'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'previous_register_read'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'read_end'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'current_register_read'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'quantity'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'uom'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'uom'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'quality_method'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'basic_data'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'current_quality_method'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'Reading'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58', '59', '60', '61', '62', '63', '64', '65']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 't_start'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 't_end'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'uom'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'quality_method'}; {'id': '62', 'type': 'string', 'children': [], 'value': '""'}; {'id': '63', 'type': 'string', 'children': [], 'value': '""'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'read_start'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'read_end'}
|
Calculate the interval between two manual readings
|
def to_rec(samples, default_keys=None):
recs = samples_to_records([normalize_missing(utils.to_single_data(x)) for x in samples], default_keys)
return [[x] for x in recs]
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_rec'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'samples'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'default_keys'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '29']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'recs'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'samples_to_records'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '28']}; {'id': '15', 'type': 'list_comprehension', 'children': ['16', '25']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'normalize_missing'}; {'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': 'utils'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'to_single_data'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'samples'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'default_keys'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'list_comprehension', 'children': ['31', '33']}; {'id': '31', 'type': 'list', 'children': ['32'], 'value': '[x]'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '33', 'type': 'for_in_clause', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'recs'}
|
Convert inputs into CWL records, useful for single item parallelization.
|
def current(self):
config = self.alembic_config()
script = ScriptDirectory.from_config(config)
revision = 'base'
def display_version(rev, context):
for rev in script.get_all_current(rev):
nonlocal revision
revision = rev.cmd_format(False)
return []
with EnvironmentContext(config, script, fn=display_version):
script.run_env()
return revision
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'current'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '23', '27', '55', '73']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'config'}; {'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': 'alembic_config'}; {'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': 'script'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ScriptDirectory'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'from_config'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'revision'}; {'id': '26', 'type': 'string', 'children': [], 'value': "'base'"}; {'id': '27', 'type': 'function_definition', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'function_name', 'children': [], 'value': 'display_version'}; {'id': '29', 'type': 'parameters', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '32', 'type': 'block', 'children': ['33', '53']}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '41']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get_all_current'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '41', 'type': 'block', 'children': ['42', '44']}; {'id': '42', 'type': 'nonlocal_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'revision'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'revision'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'cmd_format'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'False', 'children': []}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '55', 'type': 'with_statement', 'children': ['56', '66']}; {'id': '56', 'type': 'with_clause', 'children': ['57']}; {'id': '57', 'type': 'with_item', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'EnvironmentContext'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'display_version'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'script'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'run_env'}; {'id': '72', 'type': 'argument_list', 'children': []}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'revision'}
|
Display the current database revision
|
def outfile(self):
return os.path.join(OPTIONS['base_dir'],
'{0}.{1}'.format(self.name, OPTIONS['out_ext']))
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'outfile'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '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': 'join'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17']}; {'id': '14', 'type': 'subscript', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'OPTIONS'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'base_dir'"}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'{0}.{1}'"}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'OPTIONS'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'out_ext'"}
|
Path of the output file
|
def score_small_straight_yatzy(dice: List[int]) -> int:
dice_set = set(dice)
if _are_two_sets_equal({1, 2, 3, 4, 5}, dice_set):
return sum(dice)
return 0
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'score_small_straight_yatzy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dice'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '14', 'type': 'block', 'children': ['15', '22', '39']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'dice_set'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'dice'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '33']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_are_two_sets_equal'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '32']}; {'id': '26', 'type': 'set', 'children': ['27', '28', '29', '30', '31']}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dice_set'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dice'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}
|
Small straight scoring according to yatzy rules
|
def model(self):
try:
return self.data.get('identity').get('model_name')
except (KeyError, AttributeError):
return self.device_status_simple('')
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'model'}; {'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', '22']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '20']}; {'id': '10', 'type': 'attribute', 'children': ['11', '19']}; {'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': 'data'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'identity'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'model_name'"}; {'id': '22', 'type': 'except_clause', 'children': ['23', '26']}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'device_status_simple'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "''"}
|
Return the model name of the printer.
|
def tools(self, extra_params=None):
return self.api._get_json(
SpaceTool,
space=self,
rel_path=self._build_rel_path('space_tools'),
extra_params=extra_params,
)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tools'}; {'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': 'extra_params'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_get_json'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '21', '29']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'SpaceTool'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'space'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'rel_path'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_build_rel_path'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'space_tools'"}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'extra_params'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'extra_params'}
|
All Tools in this Space
|
def main(port=8222):
loop = asyncio.get_event_loop()
environ = {'hello': 'world'}
def create_server():
return MySSHServer(lambda: environ)
print('Listening on :%i' % port)
print('To connect, do "ssh localhost -p %i"' % port)
loop.run_until_complete(
asyncssh.create_server(create_server, '', port,
server_host_keys=['/etc/ssh/ssh_host_dsa_key']))
loop.run_forever()
|
{'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': 'port'}; {'id': '6', 'type': 'integer', 'children': [], 'value': '8222'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '23', '33', '40', '47', '65']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_event_loop'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '19', 'type': 'dictionary', 'children': ['20']}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'hello'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'world'"}; {'id': '23', 'type': 'function_definition', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'function_name', 'children': [], 'value': 'create_server'}; {'id': '25', 'type': 'parameters', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'MySSHServer'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'lambda', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '%'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'Listening on :%i'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '46'], 'value': '%'}; {'id': '45', 'type': 'string', 'children': [], 'value': '\'To connect, do "ssh localhost -p %i"\''}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'port'}; {'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': 'loop'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'run_until_complete'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'asyncssh'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'create_server'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59', '60', '61']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'create_server'}; {'id': '59', 'type': 'string', 'children': [], 'value': "''"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'server_host_keys'}; {'id': '63', 'type': 'list', 'children': ['64'], 'value': "['/etc/ssh/ssh_host_dsa_key']"}; {'id': '64', 'type': 'string', 'children': [], 'value': "'/etc/ssh/ssh_host_dsa_key'"}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'run_forever'}; {'id': '70', 'type': 'argument_list', 'children': []}
|
Example that starts the REPL through an SSH server.
|
async def get_devices(self, covers_only: bool = True) -> list:
from .device import MyQDevice
_LOGGER.debug('Retrieving list of devices')
devices_resp = await self._request('get', DEVICE_LIST_ENDPOINT)
device_list = []
if devices_resp is None:
return device_list
for device in devices_resp['Devices']:
if not covers_only or \
device['MyQDeviceTypeName'] in SUPPORTED_DEVICE_TYPE_NAMES:
self._devices.append({
'device_id': device['MyQDeviceId'],
'device_info': device
})
myq_device = MyQDevice(
self._devices[-1], self._brand, self)
device_list.append(myq_device)
self._store_device_states(devices_resp.get('Devices', []))
_LOGGER.debug('List of devices retrieved')
return device_list
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_devices'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_default_parameter', 'children': ['6', '7', '9']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'covers_only'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '9', 'type': 'True', 'children': []}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '12', 'type': 'block', 'children': ['13', '20', '27', '38', '42', '49', '106', '119', '126']}; {'id': '13', 'type': 'import_from_statement', 'children': ['14', '18']}; {'id': '14', 'type': 'relative_import', 'children': ['15', '16']}; {'id': '15', 'type': 'import_prefix', 'children': []}; {'id': '16', 'type': 'dotted_name', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '18', 'type': 'dotted_name', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'MyQDevice'}; {'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': '_LOGGER'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'Retrieving list of devices'"}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'devices_resp'}; {'id': '30', 'type': 'await', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_request'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'get'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'DEVICE_LIST_ENDPOINT'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'device_list'}; {'id': '41', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '46']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': 'is'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'devices_resp'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'device_list'}; {'id': '49', 'type': 'for_statement', 'children': ['50', '51', '54']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'devices_resp'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'Devices'"}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'if_statement', 'children': ['56', '65']}; {'id': '56', 'type': 'boolean_operator', 'children': ['57', '59', '60'], 'value': 'or'}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'covers_only'}; {'id': '59', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '64'], 'value': 'in'}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'MyQDeviceTypeName'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'SUPPORTED_DEVICE_TYPE_NAMES'}; {'id': '65', 'type': 'block', 'children': ['66', '83', '99']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_devices'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'dictionary', 'children': ['75', '80']}; {'id': '75', 'type': 'pair', 'children': ['76', '77']}; {'id': '76', 'type': 'string', 'children': [], 'value': "'device_id'"}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'MyQDeviceId'"}; {'id': '80', 'type': 'pair', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': "'device_info'"}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'device'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'myq_device'}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'MyQDevice'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '95', '98']}; {'id': '89', 'type': 'subscript', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_devices'}; {'id': '93', 'type': 'unary_operator', 'children': ['94'], 'value': '-'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': '_brand'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'device_list'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'myq_device'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '111']}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': '_store_device_states'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'devices_resp'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '118']}; {'id': '117', 'type': 'string', 'children': [], 'value': "'Devices'"}; {'id': '118', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': '_LOGGER'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'string', 'children': [], 'value': "'List of devices retrieved'"}; {'id': '126', 'type': 'return_statement', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'device_list'}
|
Get a list of all devices associated with the account.
|
def create_prefix_dir(self, path, fmt):
create_prefix_dir(self._get_os_path(path.strip('/')), fmt)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_prefix_dir'}; {'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': 'fmt'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'create_prefix_dir'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '23']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_get_os_path'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'fmt'}
|
Create the prefix dir, if missing
|
def make_err(self, body: str, key: str = 'report path') -> InvalidRequest:
msg = f'Could not find {key} in {self.__class__.__name__} response\n'
return InvalidRequest(msg + body)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_err'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'typed_default_parameter', 'children': ['10', '11', '13']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'report path'"}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'InvalidRequest'}; {'id': '16', 'type': 'block', 'children': ['17', '21']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '20', 'type': 'string', 'children': [], 'value': "f'Could not find {key} in {self.__class__.__name__} response\\n'"}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'InvalidRequest'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '+'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'body'}
|
Returns an InvalidRequest exception with formatted error message
|
def aes_kdf(key, rounds, password=None, keyfile=None):
cipher = AES.new(key, AES.MODE_ECB)
key_composite = compute_key_composite(
password=password,
keyfile=keyfile
)
transformed_key = key_composite
for _ in range(0, rounds):
transformed_key = cipher.encrypt(transformed_key)
return hashlib.sha256(transformed_key).digest()
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aes_kdf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rounds'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'keyfile'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '25', '37', '41', '58']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'cipher'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'AES'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'AES'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'MODE_ECB'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'key_composite'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'compute_key_composite'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'keyfile'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'keyfile'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'transformed_key'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'key_composite'}; {'id': '41', 'type': 'for_statement', 'children': ['42', '43', '48']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'rounds'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'transformed_key'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cipher'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'encrypt'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'transformed_key'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '68']}; {'id': '60', 'type': 'attribute', 'children': ['61', '67']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'hashlib'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'sha256'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'transformed_key'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'digest'}; {'id': '68', 'type': 'argument_list', 'children': []}
|
Set up a context for AES128-ECB encryption to find transformed_key
|
def shape(self, shape=None):
if shape is None:
return self._shape
data, color = self.renderer.manager.set_shape(self.model.id, shape)
self.model.data = data
self.color = color
self._shape = shape
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shape'}; {'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': 'shape'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '18', '38', '46', '52']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_shape'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '23', 'type': 'call', 'children': ['24', '31']}; {'id': '24', 'type': 'attribute', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'renderer'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'set_shape'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_shape'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'shape'}
|
We need to shift buffers in order to change shape
|
def guess_fill_char( left_comp, right_comp ):
return "*"
if ( left_comp.src == right_comp.src and left_comp.strand != right_comp.strand ):
if left_comp.end == right_comp.start:
return "-"
return "*"
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'guess_fill_char'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'left_comp'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'right_comp'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '38']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': '"*"'}; {'id': '9', 'type': 'if_statement', 'children': ['10', '26']}; {'id': '10', 'type': '()', 'children': ['11']}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '19'], 'value': 'and'}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '16'], 'value': '=='}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'left_comp'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'right_comp'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '23'], 'value': '!='}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'left_comp'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'strand'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'right_comp'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'strand'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'if_statement', 'children': ['28', '35']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': '=='}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'left_comp'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'right_comp'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"-"'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"*"'}
|
For the case where there is no annotated synteny we will try to guess it
|
def add(args):
session = c.Session(args)
if args["name"] in session.feeds.sections():
sys.exit("You already have a feed with that name.")
if args["name"] in ["all", "DEFAULT"]:
sys.exit(
("greg uses ""{}"" for a special purpose."
"Please choose another name for your feed.").format(args["name"]))
entry = {}
for key, value in args.items():
if value is not None and key != "func" and key != "name":
entry[key] = value
session.feeds[args["name"]] = entry
with open(session.data_filename, 'w') as configfile:
session.feeds.write(configfile)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '35', '63', '67', '96', '106']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Session'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '27']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '20'], 'value': 'in'}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"name"'}; {'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': 'session'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'feeds'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sections'}; {'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': 'sys'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"You already have a feed with that name."'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '43']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '40'], 'value': 'in'}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '40', 'type': 'list', 'children': ['41', '42'], 'value': '["all", "DEFAULT"]'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"all"'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"DEFAULT"'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '59']}; {'id': '51', 'type': 'attribute', 'children': ['52', '58']}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'concatenated_string', 'children': ['54', '55', '56', '57']}; {'id': '54', 'type': 'string', 'children': [], 'value': '"greg uses "'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"{}"'}; {'id': '56', 'type': 'string', 'children': [], 'value': '" for a special purpose."'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"Please choose another name for your feed."'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '66', 'type': 'dictionary', 'children': []}; {'id': '67', 'type': 'for_statement', 'children': ['68', '71', '76']}; {'id': '68', 'type': 'pattern_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'if_statement', 'children': ['78', '89']}; {'id': '78', 'type': 'boolean_operator', 'children': ['79', '86'], 'value': 'and'}; {'id': '79', 'type': 'boolean_operator', 'children': ['80', '83'], 'value': 'and'}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'is not'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '82', 'type': 'None', 'children': []}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '85'], 'value': '!='}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '85', 'type': 'string', 'children': [], 'value': '"func"'}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '88'], 'value': '!='}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '88', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '95']}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '105']}; {'id': '98', 'type': 'subscript', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'feeds'}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '104', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '106', 'type': 'with_statement', 'children': ['107', '119']}; {'id': '107', 'type': 'with_clause', 'children': ['108']}; {'id': '108', 'type': 'with_item', 'children': ['109']}; {'id': '109', 'type': 'as_pattern', 'children': ['110', '117']}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'data_filename'}; {'id': '116', 'type': 'string', 'children': [], 'value': "'w'"}; {'id': '117', 'type': 'as_pattern_target', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'configfile'}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'call', 'children': ['122', '127']}; {'id': '122', 'type': 'attribute', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'feeds'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'configfile'}
|
Add a new feed
|
def render_item(self, contentitem):
plugin = contentitem.plugin
if not plugin.search_output and not plugin.search_fields:
raise SkipItem
if not plugin.search_output:
output = ContentItemOutput('', cacheable=False)
else:
output = super(SearchRenderingPipe, self).render_item(contentitem)
if plugin.search_fields:
output.html += plugin.get_search_text(contentitem)
output.cacheable = False
return output
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_item'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'contentitem'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '26', '57', '79']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'contentitem'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '13', 'type': 'if_statement', 'children': ['14', '23']}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '19'], 'value': 'and'}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'search_output'}; {'id': '19', 'type': 'not_operator', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'search_fields'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'raise_statement', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'SkipItem'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '31', '42']}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'search_output'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ContentItemOutput'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "''"}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'cacheable'}; {'id': '41', 'type': 'False', 'children': []}; {'id': '42', 'type': 'else_clause', 'children': ['43']}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '47', 'type': 'call', 'children': ['48', '55']}; {'id': '48', 'type': 'attribute', 'children': ['49', '54']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'SearchRenderingPipe'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'render_item'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'contentitem'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'search_fields'}; {'id': '61', 'type': 'block', 'children': ['62', '73']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'augmented_assignment', 'children': ['64', '67'], 'value': '+='}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'get_search_text'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'contentitem'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cacheable'}; {'id': '78', 'type': 'False', 'children': []}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'output'}
|
Render the item - but render as search text instead.
|
def tool_options_from_global(global_options, num_jobs):
internal_opt = ["whitelist", "blacklist", "fix_what_you_can"]
queue_object = _obtain_queue(num_jobs)
translate = defaultdict(lambda: (lambda x: x),
log_technical_terms_to=lambda _: queue_object)
tool_options = OrderedDict()
for key in sorted(global_options.keys()):
if key not in internal_opt and global_options[key] is not None:
tool_options[key] = translate[key](global_options[key])
return tool_options
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tool_options_from_global'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'global_options'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'num_jobs'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '21', '39', '45', '80']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'internal_opt'}; {'id': '10', 'type': 'list', 'children': ['11', '12', '13'], 'value': '["whitelist", "blacklist", "fix_what_you_can"]'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"whitelist"'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"blacklist"'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"fix_what_you_can"'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'queue_object'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_obtain_queue'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'num_jobs'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'translate'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'defaultdict'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '33']}; {'id': '27', 'type': 'lambda', 'children': ['28']}; {'id': '28', 'type': '()', 'children': ['29']}; {'id': '29', 'type': 'lambda', 'children': ['30', '32']}; {'id': '30', 'type': 'lambda_parameters', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'log_technical_terms_to'}; {'id': '35', 'type': 'lambda', 'children': ['36', '38']}; {'id': '36', 'type': 'lambda_parameters', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'queue_object'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'tool_options'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'for_statement', 'children': ['46', '47', '55']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'global_options'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'if_statement', 'children': ['57', '66']}; {'id': '57', 'type': 'boolean_operator', 'children': ['58', '61'], 'value': 'and'}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'not in'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'internal_opt'}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '65'], 'value': 'is not'}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'global_options'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '72']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'tool_options'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'translate'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'global_options'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'tool_options'}
|
From an argparse namespace, get a dict of options for the tools.
|
def convert_bool(key, val, attr_type, attr={}, cdata=False):
LOG.info('Inside convert_bool(): key="%s", val="%s", type(val) is: "%s"' % (
unicode_me(key), unicode_me(val), type(val).__name__)
)
key, attr = make_valid_xml_name(key, attr)
if attr_type:
attr['type'] = get_xml_type(val)
attrstring = make_attrstring(attr)
return '<%s%s>%s</%s>' % (key, attrstring, unicode(val).lower(), key)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_bool'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'attr_type'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cdata'}; {'id': '12', 'type': 'False', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '37', '47', '59', '66']}; {'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': 'LOG'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}; {'id': '21', 'type': 'string', 'children': [], 'value': '\'Inside convert_bool(): key="%s", val="%s", type(val) is: "%s"\''}; {'id': '22', 'type': 'tuple', 'children': ['23', '27', '31']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'unicode_me'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'unicode_me'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '31', 'type': 'attribute', 'children': ['32', '36']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '42']}; {'id': '39', 'type': 'pattern_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'make_valid_xml_name'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'attr_type'}; {'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': 'attr'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'get_xml_type'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'attrstring'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'make_attrstring'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '69'], 'value': '%'}; {'id': '68', 'type': 'string', 'children': [], 'value': "'<%s%s>%s</%s>'"}; {'id': '69', 'type': 'tuple', 'children': ['70', '71', '72', '80']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'attrstring'}; {'id': '72', 'type': 'call', 'children': ['73', '79']}; {'id': '73', 'type': 'attribute', 'children': ['74', '78']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'unicode'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '79', 'type': 'argument_list', 'children': []}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'key'}
|
Converts a boolean into an XML element
|
def n_yearly_publications(self, refresh=True):
pub_years = [int(ab.coverDate.split('-')[0])
for ab in self.get_journal_abstracts(refresh=refresh)]
return Counter(pub_years)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'n_yearly_publications'}; {'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': 'refresh'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '36']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pub_years'}; {'id': '12', 'type': 'list_comprehension', 'children': ['13', '26']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'subscript', 'children': ['17', '25']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ab'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'coverDate'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ab'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get_journal_abstracts'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'refresh'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'refresh'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Counter'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'pub_years'}
|
Number of journal publications in a given year.
|
def lrn(self, depth_radius, bias, alpha, beta):
name = "lrn" + str(self.counts["lrn"])
self.counts["lrn"] += 1
self.top_layer = tf.nn.lrn(
self.top_layer, depth_radius, bias, alpha, beta, name=name)
return self.top_layer
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lrn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'depth_radius'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'bias'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'alpha'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'beta'}; {'id': '9', 'type': 'block', 'children': ['10', '23', '31', '53']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '15'], 'value': '+'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"lrn"'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"lrn"'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'augmented_assignment', 'children': ['25', '30'], 'value': '+='}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'counts'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"lrn"'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'top_layer'}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'nn'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'lrn'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46', '47', '48', '49', '50']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'top_layer'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'depth_radius'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'bias'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'alpha'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'beta'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'top_layer'}
|
Adds a local response normalization layer.
|
def trylock(self):
"Try to acquire lock and return True; if cannot acquire the lock at this moment, return False."
if self.locked:
return True
if self.lockroutine:
return False
waiter = self.scheduler.send(LockEvent(self.context, self.key, self))
if waiter:
return False
else:
self.locked = True
return True
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trylock'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '15', '22', '42']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': '"Try to acquire lock and return True; if cannot acquire the lock at this moment, return False."'}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'locked'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'True', 'children': []}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'lockroutine'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'False', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'waiter'}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'scheduler'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'LockEvent'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '38', '41']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '44', '47']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'waiter'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'False', 'children': []}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49', '55']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'locked'}; {'id': '54', 'type': 'True', 'children': []}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'True', 'children': []}
|
Try to acquire lock and return True; if cannot acquire the lock at this moment, return False.
|
def update_value(self, block_id, field, value):
block_name = self._db.get_block(block_id)
for name in block_name:
self._db.set_value(name, field, value)
|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'block_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'block', 'children': ['9', '20']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'block_name'}; {'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': '_db'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_block'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'block_id'}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'block_name'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_db'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'set_value'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'value'}
|
Update the value of the given block id and field
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.