code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def Screens(self, text, prog, screen, clock): BaseScreen.__init__(self, self.size, self.background) xmid = self.size[0]//2 Linesoftext(text, (xmid, 40), xmid=True, surface=self.image, fontsize=30) self.buttonlist = [] if prog == 0: self.buttonlist += [self.nextbutton] elif prog == 1: self.buttonlist += [self.nextbutton] self.buttonlist += [self.backbutton] elif prog == 2: self.buttonlist += [self.lastbutton] self.buttonlist += [self.backbutton] for i in self.buttonlist: self.image.blit(*i.blitinfo) return Menu.update(self, screen, clock)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Screens'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'prog'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'screen'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'clock'}; {'id': '9', 'type': 'block', 'children': ['10', '23', '33', '52', '58', '118', '136']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'BaseScreen'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '__init__'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '20']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'background'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'xmid'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '32'], 'value': '//'}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'Linesoftext'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38', '41', '44', '49']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '38', 'type': 'tuple', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'xmid'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '40'}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'xmid'}; {'id': '43', 'type': 'True', 'children': []}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'surface'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fontsize'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '30'}; {'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': 'buttonlist'}; {'id': '57', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '62', '72', '95']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': '=='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'prog'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'augmented_assignment', 'children': ['65', '68'], 'value': '+='}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'buttonlist'}; {'id': '68', 'type': 'list', 'children': ['69'], 'value': '[self.nextbutton]'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'nextbutton'}; {'id': '72', 'type': 'elif_clause', 'children': ['73', '76']}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '75'], 'value': '=='}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'prog'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'block', 'children': ['77', '86']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'augmented_assignment', 'children': ['79', '82'], 'value': '+='}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'buttonlist'}; {'id': '82', 'type': 'list', 'children': ['83'], 'value': '[self.nextbutton]'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'nextbutton'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'augmented_assignment', 'children': ['88', '91'], 'value': '+='}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'buttonlist'}; {'id': '91', 'type': 'list', 'children': ['92'], 'value': '[self.backbutton]'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'backbutton'}; {'id': '95', 'type': 'elif_clause', 'children': ['96', '99']}; {'id': '96', 'type': 'comparison_operator', 'children': ['97', '98'], 'value': '=='}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'prog'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '99', 'type': 'block', 'children': ['100', '109']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'augmented_assignment', 'children': ['102', '105'], 'value': '+='}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'buttonlist'}; {'id': '105', 'type': 'list', 'children': ['106'], 'value': '[self.lastbutton]'}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'lastbutton'}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'augmented_assignment', 'children': ['111', '114'], 'value': '+='}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'buttonlist'}; {'id': '114', 'type': 'list', 'children': ['115'], 'value': '[self.backbutton]'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'backbutton'}; {'id': '118', 'type': 'for_statement', 'children': ['119', '120', '123']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'buttonlist'}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '131']}; {'id': '126', 'type': 'attribute', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'blit'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'list_splat', 'children': ['133']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'blitinfo'}; {'id': '136', 'type': 'return_statement', 'children': ['137']}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'Menu'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '141', 'type': 'argument_list', 'children': ['142', '143', '144']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'screen'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'clock'}
Prog = 0 for first page, 1 for middle pages, 2 for last page
def on_bottom_align_toggled(self, chk): v = chk.get_active() self.settings.general.set_int('window-valignment', ALIGN_BOTTOM if v else ALIGN_TOP)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_bottom_align_toggled'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'chk'}; {'id': '6', 'type': 'block', 'children': ['7', '15']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'chk'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_active'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '24']}; {'id': '17', 'type': 'attribute', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'general'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'set_int'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'window-valignment'"}; {'id': '26', 'type': 'conditional_expression', 'children': ['27', '28', '29'], 'value': 'if'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ALIGN_BOTTOM'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ALIGN_TOP'}
set the vertical alignment setting.
def date_for_str(date_str): try: for date_format in itertools.permutations(['%Y','%m','%d']): try: date = datetime.strptime(date_str,''.join(date_format)) raise StopIteration except ValueError: pass return None except StopIteration: return date
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'date_for_str'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'date_str'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '45']}; {'id': '7', 'type': 'block', 'children': ['8', '43']}; {'id': '8', 'type': 'for_statement', 'children': ['9', '10', '19']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'date_format'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'itertools'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'permutations'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'list', 'children': ['16', '17', '18'], 'value': "['%Y','%m','%d']"}; {'id': '16', 'type': 'string', 'children': [], 'value': "'%Y'"}; {'id': '17', 'type': 'string', 'children': [], 'value': "'%m'"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'%d'"}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'try_statement', 'children': ['21', '39']}; {'id': '21', 'type': 'block', 'children': ['22', '37']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'strptime'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'date_str'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "''"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'date_format'}; {'id': '37', 'type': 'raise_statement', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'StopIteration'}; {'id': '39', 'type': 'except_clause', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'pass_statement', 'children': []}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'None', 'children': []}; {'id': '45', 'type': 'except_clause', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'StopIteration'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'date'}
tries to guess date from ambiguous date string
def gen403(request, baseURI, reason, project=None): orgas = None public_ask = False if not settings.PIAPI_STANDALONE: from organizations.models import Organization if project and project.plugItLimitOrgaJoinable: orgas = project.plugItOrgaJoinable.order_by('name').all() else: orgas = Organization.objects.order_by('name').all() rorgas = [] for o in orgas: if str(o.pk) == settings.VISITOR_ORGA_PK: public_ask = True else: rorgas.append(o) orgas = rorgas return HttpResponseForbidden(render_to_response('plugIt/403.html', {'context': { 'reason': reason, 'orgas': orgas, 'public_ask': public_ask, 'ebuio_baseUrl': baseURI, 'ebuio_userMode': request.session.get('plugit-standalone-usermode', 'ano'), }, 'project': project }, context_instance=RequestContext(request)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen403'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'baseURI'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '15', '19', '107']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'orgas'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'public_ask'}; {'id': '18', 'type': 'False', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '24']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'PIAPI_STANDALONE'}; {'id': '24', 'type': 'block', 'children': ['25', '31', '70', '74', '103']}; {'id': '25', 'type': 'import_from_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'dotted_name', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'organizations'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '29', 'type': 'dotted_name', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Organization'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37', '53']}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '34'], 'value': 'and'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'plugItLimitOrgaJoinable'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'orgas'}; {'id': '41', 'type': 'call', 'children': ['42', '52']}; {'id': '42', 'type': 'attribute', 'children': ['43', '51']}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'plugItOrgaJoinable'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'order_by'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'id': '53', 'type': 'else_clause', 'children': ['54']}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'orgas'}; {'id': '58', 'type': 'call', 'children': ['59', '69']}; {'id': '59', 'type': 'attribute', 'children': ['60', '68']}; {'id': '60', 'type': 'call', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'Organization'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'order_by'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'rorgas'}; {'id': '73', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '74', 'type': 'for_statement', 'children': ['75', '76', '77']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'orgas'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'if_statement', 'children': ['79', '89', '94']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '86'], 'value': '=='}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'VISITOR_ORGA_PK'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'public_ask'}; {'id': '93', 'type': 'True', 'children': []}; {'id': '94', 'type': 'else_clause', 'children': ['95']}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'rorgas'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'o'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'orgas'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'rorgas'}; {'id': '107', 'type': 'return_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'HttpResponseForbidden'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'render_to_response'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '115', '145']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'plugIt/403.html'"}; {'id': '115', 'type': 'dictionary', 'children': ['116', '142']}; {'id': '116', 'type': 'pair', 'children': ['117', '118']}; {'id': '117', 'type': 'string', 'children': [], 'value': "'context'"}; {'id': '118', 'type': 'dictionary', 'children': ['119', '122', '125', '128', '131']}; {'id': '119', 'type': 'pair', 'children': ['120', '121']}; {'id': '120', 'type': 'string', 'children': [], 'value': "'reason'"}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'reason'}; {'id': '122', 'type': 'pair', 'children': ['123', '124']}; {'id': '123', 'type': 'string', 'children': [], 'value': "'orgas'"}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'orgas'}; {'id': '125', 'type': 'pair', 'children': ['126', '127']}; {'id': '126', 'type': 'string', 'children': [], 'value': "'public_ask'"}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'public_ask'}; {'id': '128', 'type': 'pair', 'children': ['129', '130']}; {'id': '129', 'type': 'string', 'children': [], 'value': "'ebuio_baseUrl'"}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'baseURI'}; {'id': '131', 'type': 'pair', 'children': ['132', '133']}; {'id': '132', 'type': 'string', 'children': [], 'value': "'ebuio_userMode'"}; {'id': '133', 'type': 'call', 'children': ['134', '139']}; {'id': '134', 'type': 'attribute', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141']}; {'id': '140', 'type': 'string', 'children': [], 'value': "'plugit-standalone-usermode'"}; {'id': '141', 'type': 'string', 'children': [], 'value': "'ano'"}; {'id': '142', 'type': 'pair', 'children': ['143', '144']}; {'id': '143', 'type': 'string', 'children': [], 'value': "'project'"}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'context_instance'}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'RequestContext'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'request'}
Return a 403 error
def _filter_results(self, result, anchor): valid = True try: cat_tag = result.find('a', {'rel': 'category tag'}).string title = anchor.string.lower() date_tag = result.find('time').string except (AttributeError, TypeError): return False if cat_tag != "Daily Ratings": valid = False if not date_in_range(self.date, date_tag, 5): valid = False if self.category == 'cable' and 'cable' not in title: valid = False elif self.category != 'cable' and 'cable' in title: valid = False return valid
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_filter_results'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'anchor'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '57', '66', '81', '111']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '11', 'type': 'True', 'children': []}; {'id': '12', 'type': 'try_statement', 'children': ['13', '50']}; {'id': '13', 'type': 'block', 'children': ['14', '29', '39']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cat_tag'}; {'id': '17', 'type': 'attribute', 'children': ['18', '28']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'a'"}; {'id': '24', 'type': 'dictionary', 'children': ['25']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'rel'"}; {'id': '27', 'type': 'string', 'children': [], 'value': "'category tag'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'anchor'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'date_tag'}; {'id': '42', 'type': 'attribute', 'children': ['43', '49']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'time'"}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '50', 'type': 'except_clause', 'children': ['51', '54']}; {'id': '51', 'type': 'tuple', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'False', 'children': []}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': '!='}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'cat_tag'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"Daily Ratings"'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '65', 'type': 'False', 'children': []}; {'id': '66', 'type': 'if_statement', 'children': ['67', '76']}; {'id': '67', 'type': 'not_operator', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'date_in_range'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '74', '75']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'date_tag'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '5'}; {'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': 'valid'}; {'id': '80', 'type': 'False', 'children': []}; {'id': '81', 'type': 'if_statement', 'children': ['82', '91', '96']}; {'id': '82', 'type': 'boolean_operator', 'children': ['83', '88'], 'value': 'and'}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '87'], 'value': '=='}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '87', 'type': 'string', 'children': [], 'value': "'cable'"}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '90'], 'value': 'not in'}; {'id': '89', 'type': 'string', 'children': [], 'value': "'cable'"}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '95', 'type': 'False', 'children': []}; {'id': '96', 'type': 'elif_clause', 'children': ['97', '106']}; {'id': '97', 'type': 'boolean_operator', 'children': ['98', '103'], 'value': 'and'}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '102'], 'value': '!='}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '102', 'type': 'string', 'children': [], 'value': "'cable'"}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '105'], 'value': 'in'}; {'id': '104', 'type': 'string', 'children': [], 'value': "'cable'"}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '110', 'type': 'False', 'children': []}; {'id': '111', 'type': 'return_statement', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'valid'}
Filter search results by checking category titles and dates
def execute_policy(self, scaling_group, policy): return self._manager.execute_policy(scaling_group=scaling_group, policy=policy)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute_policy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scaling_group'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_manager'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'execute_policy'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'scaling_group'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'scaling_group'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'policy'}
Executes the specified policy for the scaling group.
def on_exception(self, exception): logger.error('Exception from stream!', exc_info=True) self.streaming_exception = exception
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_exception'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'Exception from stream!'"}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'exc_info'}; {'id': '16', 'type': 'True', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'streaming_exception'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'exception'}
An exception occurred in the streaming thread
def check_matching_coordinates(func): @functools.wraps(func) def wrapper(*args, **kwargs): data_arrays = ([a for a in args if isinstance(a, xr.DataArray)] + [a for a in kwargs.values() if isinstance(a, xr.DataArray)]) if len(data_arrays) > 1: first = data_arrays[0] for other in data_arrays[1:]: if not first.metpy.coordinates_identical(other): raise ValueError('Input DataArray arguments must be on same coordinates.') return func(*args, **kwargs) return wrapper
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_matching_coordinates'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '103']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '14']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'functools'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '14', 'type': 'function_definition', 'children': ['15', '16', '21']}; {'id': '15', 'type': 'function_name', 'children': [], 'value': 'wrapper'}; {'id': '16', 'type': 'parameters', 'children': ['17', '19']}; {'id': '17', 'type': 'list_splat_pattern', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'dictionary_splat_pattern', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '21', 'type': 'block', 'children': ['22', '57', '95']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data_arrays'}; {'id': '25', 'type': '()', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '40'], 'value': '+'}; {'id': '27', 'type': 'list_comprehension', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '29', 'type': 'for_in_clause', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '32', 'type': 'if_clause', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'xr'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'DataArray'}; {'id': '40', 'type': 'list_comprehension', 'children': ['41', '42', '49']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'if_clause', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'xr'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'DataArray'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '64']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '63'], 'value': '>'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'data_arrays'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'block', 'children': ['65', '71']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'data_arrays'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '71', 'type': 'for_statement', 'children': ['72', '73', '78']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'data_arrays'}; {'id': '75', 'type': 'slice', 'children': ['76', '77']}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'colon', 'children': []}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'if_statement', 'children': ['80', '89']}; {'id': '80', 'type': 'not_operator', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '87']}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'metpy'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'coordinates_identical'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'raise_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'string', 'children': [], 'value': "'Input DataArray arguments must be on same coordinates.'"}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '101']}; {'id': '99', 'type': 'list_splat', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '101', 'type': 'dictionary_splat', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'wrapper'}
Decorate a function to make sure all given DataArrays have matching coordinates.
def _get_axis_label(self, dim): if u(dim[:-1]).isdecimal(): n = len(self.channel_ids) return str(self.channel_ids[int(dim[:-1]) % n]) + dim[-1] else: return dim
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_axis_label'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '21', '55']}; {'id': '8', 'type': 'call', 'children': ['9', '20']}; {'id': '9', 'type': 'attribute', 'children': ['10', '19']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'u'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'subscript', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '15', 'type': 'slice', 'children': ['16', '17']}; {'id': '16', 'type': 'colon', 'children': []}; {'id': '17', 'type': 'unary_operator', 'children': ['18'], 'value': '-'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'isdecimal'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '31']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'channel_ids'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '51'], 'value': '+'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'channel_ids'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '50'], 'value': '%'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'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': '1'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dim'}; {'id': '53', 'type': 'unary_operator', 'children': ['54'], 'value': '-'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'else_clause', 'children': ['56']}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'dim'}
Return the channel id from a dimension, if applicable.
def _wrapper(self): try: res = self.func(*self.args, **self.kw) except Exception as e: self.mediator.set_error(e) else: self.mediator.set_result(res)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_wrapper'}; {'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', '24', '39']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'res'}; {'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': 'func'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '20']}; {'id': '16', 'type': 'list_splat', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'dictionary_splat', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kw'}; {'id': '24', 'type': 'except_clause', 'children': ['25', '29']}; {'id': '25', 'type': 'as_pattern', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '27', 'type': 'as_pattern_target', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'mediator'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'set_error'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '39', 'type': 'else_clause', 'children': ['40']}; {'id': '40', 'type': 'block', 'children': ['41']}; {'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': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'mediator'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'set_result'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'res'}
Wraps around a few calls which need to be made in the same thread.
def convert_from_gps_time(gps_time, gps_week=None): converted_gps_time = None gps_timestamp = float(gps_time) if gps_week != None: converted_gps_time = GPS_START + datetime.timedelta(seconds=int(gps_week) * SECS_IN_WEEK + gps_timestamp) else: os.environ['TZ'] = 'right/UTC' gps_time_as_gps = GPS_START + \ datetime.timedelta(seconds=gps_timestamp) gps_time_as_tai = gps_time_as_gps + \ datetime.timedelta(seconds=19) tai_epoch_as_tai = datetime.datetime(1970, 1, 1, 0, 0, 10) tai_timestamp = (gps_time_as_tai - tai_epoch_as_tai).total_seconds() converted_gps_time = ( datetime.datetime.utcfromtimestamp(tai_timestamp)) return converted_gps_time
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_from_gps_time'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'gps_time'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'gps_week'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '13', '20', '120']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'converted_gps_time'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'gps_timestamp'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'gps_time'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24', '45']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': '!='}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'gps_week'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'converted_gps_time'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '+'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'GPS_START'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '44'], 'value': '+'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '43'], 'value': '*'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'gps_week'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'SECS_IN_WEEK'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'gps_timestamp'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47', '55', '69', '83', '97', '108']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '54']}; {'id': '49', 'type': 'subscript', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'TZ'"}; {'id': '54', 'type': 'string', 'children': [], 'value': "'right/UTC'"}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'gps_time_as_gps'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '60', '61'], 'value': '+'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'GPS_START'}; {'id': '60', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'gps_timestamp'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'gps_time_as_tai'}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '74', '75'], 'value': '+'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'gps_time_as_gps'}; {'id': '74', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '19'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'tai_epoch_as_tai'}; {'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': 'datetime'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92', '93', '94', '95', '96']}; {'id': '91', 'type': 'integer', 'children': [], 'value': '1970'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '95', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '96', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'tai_timestamp'}; {'id': '100', 'type': 'call', 'children': ['101', '107']}; {'id': '101', 'type': 'attribute', 'children': ['102', '106']}; {'id': '102', 'type': '()', 'children': ['103']}; {'id': '103', 'type': 'binary_operator', 'children': ['104', '105'], 'value': '-'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'gps_time_as_tai'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'tai_epoch_as_tai'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'total_seconds'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'converted_gps_time'}; {'id': '111', 'type': '()', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '118']}; {'id': '113', 'type': 'attribute', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'utcfromtimestamp'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'tai_timestamp'}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'converted_gps_time'}
Convert gps time in ticks to standard time.
def featureServers(self): if self.urls == {}: return {} featuresUrls = self.urls['urls']['features'] if 'https' in featuresUrls: res = featuresUrls['https'] elif 'http' in featuresUrls: res = featuresUrls['http'] else: return None services = [] for urlHost in res: if self.isPortal: services.append(AGSAdministration( url='%s/admin' % urlHost, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)) else: services.append(Services( url='https://%s/%s/ArcGIS/admin' % (urlHost, self.portalId), securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)) return services
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'featureServers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '25', '51', '55', '128']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '11', 'type': 'dictionary', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'dictionary', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'featuresUrls'}; {'id': '18', 'type': 'subscript', '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': 'urls'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'urls'"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'features'"}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29', '36', '47']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'in'}; {'id': '27', 'type': 'string', 'children': [], 'value': "'https'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'featuresUrls'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'featuresUrls'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'https'"}; {'id': '36', 'type': 'elif_clause', 'children': ['37', '40']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'in'}; {'id': '38', 'type': 'string', 'children': [], 'value': "'http'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'featuresUrls'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'featuresUrls'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'http'"}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'return_statement', 'children': ['50']}; {'id': '50', 'type': 'None', 'children': []}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'services'}; {'id': '54', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '55', 'type': 'for_statement', 'children': ['56', '57', '58']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'urlHost'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'if_statement', 'children': ['60', '63', '93']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'isPortal'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'services'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'AGSAdministration'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '78', '83', '88']}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '%'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'%s/admin'"}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'urlHost'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '88', 'type': 'keyword_argument', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '93', 'type': 'else_clause', 'children': ['94']}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'services'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'Services'}; {'id': '103', 'type': 'argument_list', 'children': ['104', '113', '118', '123']}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '106', 'type': 'binary_operator', 'children': ['107', '108'], 'value': '%'}; {'id': '107', 'type': 'string', 'children': [], 'value': "'https://%s/%s/ArcGIS/admin'"}; {'id': '108', 'type': 'tuple', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'urlHost'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'portalId'}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '118', 'type': 'keyword_argument', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '123', 'type': 'keyword_argument', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '128', 'type': 'return_statement', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'services'}
gets the hosting feature AGS Server
def _update_Pxy_diag(self): for r in range(1): Phi_x_half = self.Phi_x**0.5 Phi_x_neghalf = self.Phi_x**-0.5 symm_p = (Phi_x_half * (self.Pxy[r] * Phi_x_neghalf).transpose()).transpose() (evals, evecs) = scipy.linalg.eigh(symm_p) self.D[r] = evals self.Ainv[r] = evecs.transpose() * Phi_x_half self.A[r] = (Phi_x_neghalf * evecs.transpose()).transpose()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_Pxy_diag'}; {'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', '12']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '12', 'type': 'block', 'children': ['13', '21', '30', '52', '65', '73', '87']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Phi_x_half'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '20'], 'value': '**'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Phi_x'}; {'id': '20', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Phi_x_neghalf'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '28'], 'value': '**'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Phi_x'}; {'id': '28', 'type': 'unary_operator', 'children': ['29'], 'value': '-'}; {'id': '29', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'symm_p'}; {'id': '33', 'type': 'call', 'children': ['34', '51']}; {'id': '34', 'type': 'attribute', 'children': ['35', '50']}; {'id': '35', 'type': '()', 'children': ['36']}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '*'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Phi_x_half'}; {'id': '38', 'type': 'call', 'children': ['39', '49']}; {'id': '39', 'type': 'attribute', 'children': ['40', '48']}; {'id': '40', 'type': '()', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '47'], 'value': '*'}; {'id': '42', 'type': 'subscript', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'Pxy'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'Phi_x_neghalf'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'transpose'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'transpose'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'tuple_pattern', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'evals'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'evecs'}; {'id': '57', 'type': 'call', 'children': ['58', '63']}; {'id': '58', 'type': 'attribute', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'scipy'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'linalg'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'eigh'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'symm_p'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '72']}; {'id': '67', 'type': 'subscript', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'D'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'evals'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '80']}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'Ainv'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '86'], 'value': '*'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'evecs'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'transpose'}; {'id': '85', 'type': 'argument_list', 'children': []}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'Phi_x_half'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '94']}; {'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': 'A'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '94', 'type': 'call', 'children': ['95', '105']}; {'id': '95', 'type': 'attribute', 'children': ['96', '104']}; {'id': '96', 'type': '()', 'children': ['97']}; {'id': '97', 'type': 'binary_operator', 'children': ['98', '99'], 'value': '*'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'Phi_x_neghalf'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'evecs'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'transpose'}; {'id': '103', 'type': 'argument_list', 'children': []}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'transpose'}; {'id': '105', 'type': 'argument_list', 'children': []}
Update `D`, `A`, `Ainv` from `Pxy`, `Phi_x`.
def _createComboBoxes(self, row): tree = self.tree model = self.tree.model() self._setColumnCountForContents() for col, _ in enumerate(self._axisNames, self.COL_FIRST_COMBO): logger.debug("Adding combobox at ({}, {})".format(row, col)) comboBox = QtWidgets.QComboBox() comboBox.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents) comboBox.activated.connect(self._comboBoxActivated) self._comboBoxes.append(comboBox) tree.setIndexWidget(model.index(row, col), comboBox)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_createComboBoxes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '23', '29']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'model'}; {'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': 'tree'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_setColumnCountForContents'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'for_statement', 'children': ['30', '33', '42']}; {'id': '30', 'type': 'pattern_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_axisNames'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'COL_FIRST_COMBO'}; {'id': '42', 'type': 'block', 'children': ['43', '56', '64', '75', '86', '95']}; {'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': 'logger'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"Adding combobox at ({}, {})"'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'comboBox'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'QtWidgets'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'QComboBox'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'comboBox'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'setSizeAdjustPolicy'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'QtWidgets'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'QComboBox'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'AdjustToContents'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '82']}; {'id': '77', 'type': 'attribute', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'comboBox'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'activated'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': '_comboBoxActivated'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '93']}; {'id': '88', 'type': 'attribute', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': '_comboBoxes'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'comboBox'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'setIndexWidget'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '108']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'comboBox'}
Creates a combo box for each of the fullAxisNames
def find_root_and_sink_variables(self): is_root = {name: True for scope in self.scopes for name in scope.variables.keys()} for operator in self.unordered_operator_iterator(): for variable in operator.outputs: is_root[variable.onnx_name] = False is_sink = {name: True for scope in self.scopes for name in scope.variables.keys()} for operator in self.unordered_operator_iterator(): for variable in operator.inputs: is_sink[variable.onnx_name] = False return [variable for scope in self.scopes for name, variable in scope.variables.items() if is_root[name] or is_sink[name]]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_root_and_sink_variables'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '27', '49', '70', '92']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'is_root'}; {'id': '9', 'type': 'dictionary_comprehension', 'children': ['10', '13', '18']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'True', 'children': []}; {'id': '13', 'type': 'for_in_clause', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'scopes'}; {'id': '18', 'type': 'for_in_clause', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', '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': 'scope'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'for_statement', 'children': ['28', '29', '34']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'unordered_operator_iterator'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '40']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'outputs'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '48']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'is_root'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'onnx_name'}; {'id': '48', 'type': 'False', 'children': []}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'is_sink'}; {'id': '52', 'type': 'dictionary_comprehension', 'children': ['53', '56', '61']}; {'id': '53', 'type': 'pair', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '55', 'type': 'True', 'children': []}; {'id': '56', 'type': 'for_in_clause', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'scopes'}; {'id': '61', 'type': 'for_in_clause', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'name'}; {'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': 'scope'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'for_statement', 'children': ['71', '72', '77']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'unordered_operator_iterator'}; {'id': '76', 'type': 'argument_list', 'children': []}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'for_statement', 'children': ['79', '80', '83']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '91']}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'is_sink'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'onnx_name'}; {'id': '91', 'type': 'False', 'children': []}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'list_comprehension', 'children': ['94', '95', '100', '111']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '95', 'type': 'for_in_clause', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'scopes'}; {'id': '100', 'type': 'for_in_clause', 'children': ['101', '104']}; {'id': '101', 'type': 'pattern_list', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '104', 'type': 'call', 'children': ['105', '110']}; {'id': '105', 'type': 'attribute', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'scope'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '110', 'type': 'argument_list', 'children': []}; {'id': '111', 'type': 'if_clause', 'children': ['112']}; {'id': '112', 'type': 'boolean_operator', 'children': ['113', '116'], 'value': 'or'}; {'id': '113', 'type': 'subscript', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'is_root'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'is_sink'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'name'}
Find root variables of the whole graph
def executor_cleanup(self): try: executor = self.get_executor(create=None) except AttributeError: pass else: if executor is not None: executor.cleanup()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'executor_cleanup'}; {'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', '19', '23']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'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_executor'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'except_clause', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'pass_statement', 'children': []}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is not'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'executor'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'cleanup'}; {'id': '35', 'type': 'argument_list', 'children': []}
Let the executor clean up any cached information.
def copy(data, start=0, stop=None, blen=None, storage=None, create='array', **kwargs): storage = _util.get_storage(storage) blen = _util.get_blen_array(data, blen) if stop is None: stop = len(data) else: stop = min(stop, len(data)) length = stop - start if length < 0: raise ValueError('invalid stop/start') out = None for i in range(start, stop, blen): j = min(i+blen, stop) block = data[i:j] if out is None: out = getattr(storage, create)(block, expectedlen=length, **kwargs) else: out.append(block) return out
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'blen'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'array'"}; {'id': '20', 'type': 'dictionary_splat_pattern', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '22', 'type': 'block', 'children': ['23', '32', '42', '67', '73', '83', '87', '145']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_util'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get_storage'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'blen'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_util'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get_blen_array'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'blen'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '46', '54']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': 'is'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '54', 'type': 'else_clause', 'children': ['55']}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '-'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '73', 'type': 'if_statement', 'children': ['74', '77']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': '<'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'raise_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'string', 'children': [], 'value': "'invalid stop/start'"}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '86', 'type': 'None', 'children': []}; {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '95']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93', '94']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'blen'}; {'id': '95', 'type': 'block', 'children': ['96', '106', '115']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '105']}; {'id': '102', 'type': 'binary_operator', 'children': ['103', '104'], 'value': '+'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'blen'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'block'}; {'id': '109', 'type': 'subscript', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '111', 'type': 'slice', 'children': ['112', '113', '114']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '113', 'type': 'colon', 'children': []}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '115', 'type': 'if_statement', 'children': ['116', '119', '136']}; {'id': '116', 'type': 'comparison_operator', 'children': ['117', '118'], 'value': 'is'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '118', 'type': 'None', 'children': []}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '123', 'type': 'call', 'children': ['124', '129']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '131', '134']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'block'}; {'id': '131', 'type': 'keyword_argument', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'expectedlen'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '134', 'type': 'dictionary_splat', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '136', 'type': 'else_clause', 'children': ['137']}; {'id': '137', 'type': 'block', 'children': ['138']}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'block'}; {'id': '145', 'type': 'return_statement', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'out'}
Copy `data` block-wise into a new array.
def parse_field(setting, field_name, default): if isinstance(setting, dict): return setting.get(field_name, default) else: return setting
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'setting'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'field_name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '14', '23']}; {'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': 'setting'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'setting'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'field_name'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'setting'}
Extract result from single-value or dict-type setting like fallback_values.
def update(self) -> None: mask = self.mask weights = self.refweights[mask] self[~mask] = numpy.nan self[mask] = weights/numpy.sum(weights)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '14', '22', '31']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'weights'}; {'id': '17', 'type': 'subscript', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'refweights'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '28']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'unary_operator', 'children': ['27'], 'value': '~'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'mask'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '38'], 'value': '/'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'weights'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'weights'}
Update subclass of |RelSubweightsMixin| based on `refweights`.
def contribute_to_class(self, cls, name, **kwargs): super(PlaceholderField, self).contribute_to_class(cls, name, **kwargs) setattr(cls, name, PlaceholderFieldDescriptor(self.slot)) if not hasattr(cls, '_meta_placeholder_fields'): cls._meta_placeholder_fields = {} cls._meta_placeholder_fields[name] = self if django.VERSION >= (1, 11): rel = self.remote_field else: rel = self.rel if rel.related_name is None: rel.related_name = '{app}_{model}_{slot}_FIXME'.format( app=cls._meta.app_label, model=cls._meta.object_name.lower(), slot=self.slot ) setattr(rel.to, self.rel.related_name, None)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'contribute_to_class'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '24', '36', '50', '58', '81']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'PlaceholderField'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'contribute_to_class'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'dictionary_splat', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'PlaceholderFieldDescriptor'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '43']}; {'id': '37', 'type': 'not_operator', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'_meta_placeholder_fields'"}; {'id': '43', 'type': 'block', 'children': ['44']}; {'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': 'cls'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_meta_placeholder_fields'}; {'id': '49', 'type': 'dictionary', 'children': []}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '57']}; {'id': '52', 'type': 'subscript', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_meta_placeholder_fields'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '66', '73']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '63'], 'value': '>='}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'django'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'VERSION'}; {'id': '63', 'type': 'tuple', 'children': ['64', '65']}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'rel'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'remote_field'}; {'id': '73', 'type': 'else_clause', 'children': ['74']}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'rel'}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'rel'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '87']}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '86'], 'value': 'is'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'rel'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'related_name'}; {'id': '86', 'type': 'None', 'children': []}; {'id': '87', 'type': 'block', 'children': ['88', '121']}; {'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': 'rel'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'related_name'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'string', 'children': [], 'value': "'{app}_{model}_{slot}_FIXME'"}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '105', '116']}; {'id': '98', 'type': 'keyword_argument', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '100', 'type': 'attribute', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'app_label'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '107', 'type': 'call', 'children': ['108', '115']}; {'id': '108', 'type': 'attribute', 'children': ['109', '114']}; {'id': '109', 'type': 'attribute', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'object_name'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '115', 'type': 'argument_list', 'children': []}; {'id': '116', 'type': 'keyword_argument', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '128', '133']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'rel'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'to'}; {'id': '128', 'type': 'attribute', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'rel'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'related_name'}; {'id': '133', 'type': 'None', 'children': []}
Internal Django method to associate the field with the Model; it assigns the descriptor.
def close_all_pages(self): states_to_be_closed = [] for state_identifier in self.tabs: states_to_be_closed.append(state_identifier) for state_identifier in states_to_be_closed: self.close_page(state_identifier, delete=False)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close_all_pages'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'states_to_be_closed'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '15']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tabs'}; {'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': 'states_to_be_closed'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'states_to_be_closed'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'close_page'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'state_identifier'}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '36', 'type': 'False', 'children': []}
Closes all tabs of the states editor
def fetch_entities(self): query = text( ) response = self.perform_query(query) entities = {} domains = set() for [entity] in response: domain = entity.split(".")[0] domains.add(domain) entities.setdefault(domain, []).append(entity) self._domains = list(domains) self._entities = entities print("There are {} entities with data".format(len(entities)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch_entities'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '21', '25', '31', '67', '76', '82']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'text'}; {'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': 'response'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'perform_query'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'entities'}; {'id': '24', 'type': 'dictionary', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'domains'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'for_statement', 'children': ['32', '34', '35']}; {'id': '32', 'type': 'list_pattern', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '35', 'type': 'block', 'children': ['36', '47', '54']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '39', 'type': 'subscript', 'children': ['40', '46']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'domains'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '65']}; {'id': '56', 'type': 'attribute', 'children': ['57', '64']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'entities'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'domain'}; {'id': '63', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'entity'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_domains'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'domains'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_entities'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'entities'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'print'}; {'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': '"There are {} entities with data"'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'entities'}
Fetch entities for which we have data.
def DeleteClientActionRequests(self, requests): if not requests: return to_delete = [] for r in requests: to_delete.append((r.client_id, r.flow_id, r.request_id)) if len(set(to_delete)) != len(to_delete): raise ValueError( "Received multiple copies of the same message to delete.") self._DeleteClientActionRequest(to_delete)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'DeleteClientActionRequests'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '6', 'type': 'block', 'children': ['7', '12', '16', '36', '55']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '10']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'to_delete'}; {'id': '15', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'to_delete'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'tuple', 'children': ['27', '30', '33']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'flow_id'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'request_id'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '49']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '45'], 'value': '!='}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'to_delete'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'to_delete'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'raise_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'string', 'children': [], 'value': '"Received multiple copies of the same message to delete."'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_DeleteClientActionRequest'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'to_delete'}
Deletes a list of client messages from the db.
def get(self, key, default=miss): if key not in self._dict: return default return self[key]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'miss'}; {'id': '9', 'type': 'block', 'children': ['10', '19']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '16']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'not in'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'subscript', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key'}
Return the value for given key if it exists.
def command_queue_worker(self, command_queue): while True: try: command, data = command_queue.get(timeout=3) try: self.process_command(command, data) except Exception as e: _logger.exception(e) self.worker_exceptions.append(e) break except Empty: pass if self.stopping and (_worker_fast_exit_on_terminate or command_queue.empty()): break
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'command_queue_worker'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'command_queue'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'while_statement', 'children': ['8', '9']}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '62']}; {'id': '10', 'type': 'try_statement', 'children': ['11', '58']}; {'id': '11', 'type': 'block', 'children': ['12', '25']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'pattern_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'command_queue'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '25', 'type': 'try_statement', 'children': ['26', '35']}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'process_command'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '35', 'type': 'except_clause', 'children': ['36', '40']}; {'id': '36', 'type': 'as_pattern', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '38', 'type': 'as_pattern_target', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '40', 'type': 'block', 'children': ['41', '48', '57']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_logger'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'worker_exceptions'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '57', 'type': 'break_statement', 'children': []}; {'id': '58', 'type': 'except_clause', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'Empty'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'pass_statement', 'children': []}; {'id': '62', 'type': 'if_statement', 'children': ['63', '75']}; {'id': '63', 'type': 'boolean_operator', 'children': ['64', '67'], 'value': 'and'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'stopping'}; {'id': '67', 'type': '()', 'children': ['68']}; {'id': '68', 'type': 'boolean_operator', 'children': ['69', '70'], 'value': 'or'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_worker_fast_exit_on_terminate'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'command_queue'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'break_statement', 'children': []}
Process commands in command queues.
def uniq(seq): seen = set() return [x for x in seq if str(x) not in seen and not seen.add(str(x))]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'uniq'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'seq'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'list_comprehension', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '15', 'type': 'for_in_clause', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'seq'}; {'id': '18', 'type': 'if_clause', 'children': ['19']}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '26'], 'value': 'and'}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '25'], 'value': 'not in'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '26', 'type': 'not_operator', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'seen'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'x'}
Return a copy of seq without duplicates.
def validate(self, obj, **kwargs): obj = stringify(obj) if obj is None: return False return self.DATE_RE.match(obj) is not None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '8', 'type': 'block', 'children': ['9', '16', '23']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'stringify'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'is'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'False', 'children': []}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '33'], 'value': 'is not'}; {'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': 'DATE_RE'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '33', 'type': 'None', 'children': []}
Check if a thing is a valid date.
def serial_lock(self, lock): mav = self.master.mav if lock: flags = mavutil.mavlink.SERIAL_CONTROL_FLAG_EXCLUSIVE self.locked = True else: flags = 0 self.locked = False mav.serial_control_send(self.serial_settings.port, flags, 0, 0, 0, [0]*70)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serial_lock'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'mav'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'master'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'mav'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '17', '32']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'id': '17', 'type': 'block', 'children': ['18', '26']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'mavutil'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'mavlink'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'SERIAL_CONTROL_FLAG_EXCLUSIVE'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'locked'}; {'id': '31', 'type': 'True', 'children': []}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34', '38']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'locked'}; {'id': '43', 'type': 'False', 'children': []}; {'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': 'mav'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'serial_control_send'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '55', '56', '57', '58', '59']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'serial_settings'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '62'], 'value': '*'}; {'id': '60', 'type': 'list', 'children': ['61'], 'value': '[0]'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '70'}
lock or unlock the port
def collect_appendvars(ap_, cls): for key, value in cls.__dict__.items(): if key.startswith('appendvars_'): varname = key[11:] if varname not in ap_.appendvars: ap_.appendvars[varname] = [] if value not in ap_.appendvars[varname]: if not isinstance(value, list): value = [value] ap_.appendvars[varname] += value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'collect_appendvars'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ap_'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '11', '18']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'value'}; {'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': 'cls'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'if_statement', 'children': ['20', '26']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'appendvars_'"}; {'id': '26', 'type': 'block', 'children': ['27', '35', '50']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '32', 'type': 'slice', 'children': ['33', '34']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '34', 'type': 'colon', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '41']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': 'not in'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ap_'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'appendvars'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '49']}; {'id': '44', 'type': 'subscript', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ap_'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'appendvars'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '49', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '58']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': 'not in'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '53', 'type': 'subscript', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ap_'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'appendvars'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '58', 'type': 'block', 'children': ['59', '72']}; {'id': '59', 'type': 'if_statement', 'children': ['60', '66']}; {'id': '60', 'type': 'not_operator', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '70', 'type': 'list', 'children': ['71'], 'value': '[value]'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'augmented_assignment', 'children': ['74', '79'], 'value': '+='}; {'id': '74', 'type': 'subscript', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ap_'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'appendvars'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'value'}
colleziona elementi per le liste.
def _pack_date(self, date): y, mon, d, h, min_, s = date.timetuple()[:6] dw1 = 0x0000FFFF & ((y>>6) & 0x0000003F) dw2 = 0x0000FFFF & ((y & 0x0000003F)<<2 | ((mon>>2) & 0x00000003)) dw3 = 0x0000FFFF & (((mon & 0x0000003)<<6) | ((d & 0x0000001F)<<1) \ | ((h>>4) & 0x00000001)) dw4 = 0x0000FFFF & (((h & 0x0000000F)<<4) | ((min_>>2) & 0x0000000F)) dw5 = 0x0000FFFF & (((min_ & 0x00000003)<<6) | (s & 0x0000003F)) return struct.pack('<5B', dw1, dw2, dw3, dw4, dw5)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_pack_date'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '6', 'type': 'block', 'children': ['7', '25', '37', '57', '87', '108', '126']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '16']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11', '12', '13', '14', '15']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'mon'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'min_'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '16', 'type': 'subscript', 'children': ['17', '22']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'timetuple'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'slice', 'children': ['23', '24']}; {'id': '23', 'type': 'colon', 'children': []}; {'id': '24', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dw1'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '&'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0x0000FFFF'}; {'id': '30', 'type': '()', 'children': ['31']}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '36'], 'value': '&'}; {'id': '32', 'type': '()', 'children': ['33']}; {'id': '33', 'type': 'binary_operator', 'children': ['34', '35'], 'value': '>>'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '0x0000003F'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dw2'}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '&'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0x0000FFFF'}; {'id': '42', 'type': '()', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '50'], 'value': '|'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '49'], 'value': '<<'}; {'id': '45', 'type': '()', 'children': ['46']}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '&'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0x0000003F'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '50', 'type': '()', 'children': ['51']}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '56'], 'value': '&'}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '55'], 'value': '>>'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'mon'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0x00000003'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'dw3'}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '&'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0x0000FFFF'}; {'id': '62', 'type': '()', 'children': ['63']}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '79', '80'], 'value': '|'}; {'id': '64', 'type': 'binary_operator', 'children': ['65', '72'], 'value': '|'}; {'id': '65', 'type': '()', 'children': ['66']}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '71'], 'value': '<<'}; {'id': '67', 'type': '()', 'children': ['68']}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '70'], 'value': '&'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'mon'}; {'id': '70', 'type': 'integer', 'children': [], 'value': '0x0000003'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '72', 'type': '()', 'children': ['73']}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '78'], 'value': '<<'}; {'id': '74', 'type': '()', 'children': ['75']}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '&'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '0x0000001F'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '79', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '80', 'type': '()', 'children': ['81']}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '86'], 'value': '&'}; {'id': '82', 'type': '()', 'children': ['83']}; {'id': '83', 'type': 'binary_operator', 'children': ['84', '85'], 'value': '>>'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '86', 'type': 'integer', 'children': [], 'value': '0x00000001'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'dw4'}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '92'], 'value': '&'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '0x0000FFFF'}; {'id': '92', 'type': '()', 'children': ['93']}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '101'], 'value': '|'}; {'id': '94', 'type': '()', 'children': ['95']}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '100'], 'value': '<<'}; {'id': '96', 'type': '()', 'children': ['97']}; {'id': '97', 'type': 'binary_operator', 'children': ['98', '99'], 'value': '&'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '99', 'type': 'integer', 'children': [], 'value': '0x0000000F'}; {'id': '100', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '101', 'type': '()', 'children': ['102']}; {'id': '102', 'type': 'binary_operator', 'children': ['103', '107'], 'value': '&'}; {'id': '103', 'type': '()', 'children': ['104']}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '106'], 'value': '>>'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'min_'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '107', 'type': 'integer', 'children': [], 'value': '0x0000000F'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'dw5'}; {'id': '111', 'type': 'binary_operator', 'children': ['112', '113'], 'value': '&'}; {'id': '112', 'type': 'integer', 'children': [], 'value': '0x0000FFFF'}; {'id': '113', 'type': '()', 'children': ['114']}; {'id': '114', 'type': 'binary_operator', 'children': ['115', '122'], 'value': '|'}; {'id': '115', 'type': '()', 'children': ['116']}; {'id': '116', 'type': 'binary_operator', 'children': ['117', '121'], 'value': '<<'}; {'id': '117', 'type': '()', 'children': ['118']}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '120'], 'value': '&'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'min_'}; {'id': '120', 'type': 'integer', 'children': [], 'value': '0x00000003'}; {'id': '121', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '122', 'type': '()', 'children': ['123']}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '125'], 'value': '&'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '125', 'type': 'integer', 'children': [], 'value': '0x0000003F'}; {'id': '126', 'type': 'return_statement', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '133', '134', '135', '136', '137']}; {'id': '132', 'type': 'string', 'children': [], 'value': "'<5B'"}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'dw1'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'dw2'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'dw3'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'dw4'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'dw5'}
This method is used to encode dates
def main(output): client = Session().client('cloudresourcemanager', 'v1', 'projects') results = [] for page in client.execute_paged_query('list', {}): for project in page.get('projects', []): if project['lifecycleState'] != 'ACTIVE': continue project_info = { 'project_id': project['projectId'], 'name': project['name'], } if 'labels' in project: project_info['tags'] = [ 'label:%s:%s' % (k, v) for k, v in project.get('labels', {}).items()] results.append(project_info) output.write( yaml.safe_dump({'projects': results}, default_flow_style=False))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '23', '103']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Session'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '18']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'cloudresourcemanager'"}; {'id': '17', 'type': 'string', 'children': [], 'value': "'v1'"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'projects'"}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '22', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '32']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'execute_paged_query'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'list'"}; {'id': '31', 'type': 'dictionary', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '42']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'projects'"}; {'id': '41', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '42', 'type': 'block', 'children': ['43', '51', '65', '96']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '49']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '48'], 'value': '!='}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'lifecycleState'"}; {'id': '48', 'type': 'string', 'children': [], 'value': "'ACTIVE'"}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'continue_statement', 'children': []}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'project_info'}; {'id': '54', 'type': 'dictionary', 'children': ['55', '60']}; {'id': '55', 'type': 'pair', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'project_id'"}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'projectId'"}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '65', 'type': 'if_statement', 'children': ['66', '69']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '68'], 'value': 'in'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'labels'"}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '75']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'project_info'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'tags'"}; {'id': '75', 'type': 'list_comprehension', 'children': ['76', '81']}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '78'], 'value': '%'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'label:%s:%s'"}; {'id': '78', 'type': 'tuple', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '81', 'type': 'for_in_clause', 'children': ['82', '85']}; {'id': '82', 'type': 'pattern_list', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '85', 'type': 'call', 'children': ['86', '95']}; {'id': '86', 'type': 'attribute', 'children': ['87', '94']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'string', 'children': [], 'value': "'labels'"}; {'id': '93', 'type': 'dictionary', 'children': []}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '95', 'type': 'argument_list', 'children': []}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'project_info'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'safe_dump'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '118']}; {'id': '114', 'type': 'dictionary', 'children': ['115']}; {'id': '115', 'type': 'pair', 'children': ['116', '117']}; {'id': '116', 'type': 'string', 'children': [], 'value': "'projects'"}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '118', 'type': 'keyword_argument', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'default_flow_style'}; {'id': '120', 'type': 'False', 'children': []}
Generate a c7n-org gcp projects config file
def transpose(attrs, inputs, proto_obj): new_attrs = translation_utils._fix_attribute_names(attrs, {'perm' : 'axes'}) return 'transpose', new_attrs, inputs
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transpose'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'inputs'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'proto_obj'}; {'id': '7', 'type': 'block', 'children': ['8', '21']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'new_attrs'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'translation_utils'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_fix_attribute_names'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'attrs'}; {'id': '17', 'type': 'dictionary', 'children': ['18']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'perm'"}; {'id': '20', 'type': 'string', 'children': [], 'value': "'axes'"}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'expression_list', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'string', 'children': [], 'value': "'transpose'"}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'new_attrs'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'inputs'}
Transpose the input array.
def create_issue(self, request, group, form_data, **kwargs): instance = self.get_option('instance', group.project) project = ( form_data.get('project') or self.get_option('default_project', group.project) ) client = self.get_client(request.user) title = form_data['title'] description = form_data['description'] link = absolute_uri(group.get_absolute_url(params={'referrer': 'vsts_plugin'})) try: created_item = client.create_work_item( instance=instance, project=project, title=title, comment=markdown(description), link=link, ) except Exception as e: self.raise_error(e, identity=client.auth) return { 'id': created_item['id'], 'url': created_item['_links']['html']['href'], 'title': title, }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_issue'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'form_data'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '23', '43', '54', '60', '66', '83', '129']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_option'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'instance'"}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '26', 'type': '()', 'children': ['27']}; {'id': '27', 'type': 'boolean_operator', 'children': ['28', '34'], 'value': 'or'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'form_data'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'project'"}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'get_option'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'default_project'"}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get_client'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'form_data'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'title'"}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'form_data'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'description'"}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'absolute_uri'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'get_absolute_url'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '79', 'type': 'dictionary', 'children': ['80']}; {'id': '80', 'type': 'pair', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': "'referrer'"}; {'id': '82', 'type': 'string', 'children': [], 'value': "'vsts_plugin'"}; {'id': '83', 'type': 'try_statement', 'children': ['84', '111']}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'created_item'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'create_work_item'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '96', '99', '102', '108']}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '96', 'type': 'keyword_argument', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'markdown'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '111', 'type': 'except_clause', 'children': ['112', '116']}; {'id': '112', 'type': 'as_pattern', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '114', 'type': 'as_pattern_target', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '116', 'type': 'block', 'children': ['117']}; {'id': '117', 'type': 'expression_statement', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'raise_error'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '124', 'type': 'keyword_argument', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'identity'}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '129', 'type': 'return_statement', 'children': ['130']}; {'id': '130', 'type': 'dictionary', 'children': ['131', '136', '145']}; {'id': '131', 'type': 'pair', 'children': ['132', '133']}; {'id': '132', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '133', 'type': 'subscript', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'created_item'}; {'id': '135', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '136', 'type': 'pair', 'children': ['137', '138']}; {'id': '137', 'type': 'string', 'children': [], 'value': "'url'"}; {'id': '138', 'type': 'subscript', 'children': ['139', '144']}; {'id': '139', 'type': 'subscript', 'children': ['140', '143']}; {'id': '140', 'type': 'subscript', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'created_item'}; {'id': '142', 'type': 'string', 'children': [], 'value': "'_links'"}; {'id': '143', 'type': 'string', 'children': [], 'value': "'html'"}; {'id': '144', 'type': 'string', 'children': [], 'value': "'href'"}; {'id': '145', 'type': 'pair', 'children': ['146', '147']}; {'id': '146', 'type': 'string', 'children': [], 'value': "'title'"}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'title'}
Creates the issue on the remote service and returns an issue ID.
def cookies(self) -> Dict[str, str]: cookies = SimpleCookie() cookies.load(self.headers.get('Cookie', '')) return {key: cookie.value for key, cookie in cookies.items()}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cookies'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'generic_type', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'Dict'}; {'id': '8', 'type': 'type_parameter', 'children': ['9', '11']}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'block', 'children': ['14', '20', '35']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cookies'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'SimpleCookie'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cookies'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'Cookie'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "''"}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'dictionary_comprehension', 'children': ['37', '42']}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'cookie'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '46']}; {'id': '43', 'type': 'pattern_list', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'cookie'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cookies'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '50', 'type': 'argument_list', 'children': []}
The parsed cookies attached to this request.
def grad_eigh(ans, x, UPLO='L'): N = x.shape[-1] w, v = ans def vjp(g): wg, vg = g w_repeated = anp.repeat(w[..., anp.newaxis], N, axis=-1) off_diag = anp.ones((N, N)) - anp.eye(N) F = off_diag / (T(w_repeated) - w_repeated + anp.eye(N)) return _dot(v * wg[..., anp.newaxis, :] + _dot(v, F * _dot(T(v), vg)), T(v)) return vjp
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'grad_eigh'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ans'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'UPLO'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'L'"}; {'id': '9', 'type': 'block', 'children': ['10', '19', '25', '125']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '13', 'type': 'subscript', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '17', 'type': 'unary_operator', 'children': ['18'], 'value': '-'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'pattern_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ans'}; {'id': '25', 'type': 'function_definition', 'children': ['26', '27', '29']}; {'id': '26', 'type': 'function_name', 'children': [], 'value': 'vjp'}; {'id': '27', 'type': 'parameters', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '29', 'type': 'block', 'children': ['30', '36', '55', '73', '92']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'wg'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'vg'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'w_repeated'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'anp'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'repeat'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '50', '51']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '46', 'type': 'ellipsis', 'children': [], 'value': '...'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'anp'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'newaxis'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '53', 'type': 'unary_operator', 'children': ['54'], 'value': '-'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'off_diag'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '67'], 'value': '-'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'anp'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ones'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'tuple', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'anp'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'eye'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'F'}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '78'], 'value': '/'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'off_diag'}; {'id': '78', 'type': '()', 'children': ['79']}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '86'], 'value': '+'}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '85'], 'value': '-'}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'w_repeated'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'w_repeated'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'anp'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'eye'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_dot'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '121']}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '107'], 'value': '+'}; {'id': '97', 'type': 'binary_operator', 'children': ['98', '99'], 'value': '*'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '99', 'type': 'subscript', 'children': ['100', '101', '102', '105']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'wg'}; {'id': '101', 'type': 'ellipsis', 'children': [], 'value': '...'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'anp'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'newaxis'}; {'id': '105', 'type': 'slice', 'children': ['106']}; {'id': '106', 'type': 'colon', 'children': []}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': '_dot'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '111', 'type': 'binary_operator', 'children': ['112', '113'], 'value': '*'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'F'}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': '_dot'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '120']}; {'id': '116', 'type': 'call', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '118', 'type': 'argument_list', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'vg'}; {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '125', 'type': 'return_statement', 'children': ['126']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'vjp'}
Gradient for eigenvalues and vectors of a symmetric matrix.
def weight_list_to_tuple(data, attr_name): if len(data['Value']) != len(data['Weight']): raise ValueError('Number of weights do not correspond to number of ' 'attributes in %s' % attr_name) weight = np.array(data['Weight']) if fabs(np.sum(weight) - 1.) > 1E-7: raise ValueError('Weights do not sum to 1.0 in %s' % attr_name) data_tuple = [] for iloc, value in enumerate(data['Value']): data_tuple.append((value, weight[iloc])) return data_tuple
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'weight_list_to_tuple'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'attr_name'}; {'id': '6', 'type': 'block', 'children': ['7', '31', '42', '64', '68', '90']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '21']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '15'], 'value': '!='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'Value'"}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'Weight'"}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'raise_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '30'], 'value': '%'}; {'id': '27', 'type': 'concatenated_string', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'Number of weights do not correspond to number of '"}; {'id': '29', 'type': 'string', 'children': [], 'value': "'attributes in %s'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'attr_name'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'weight'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'Weight'"}; {'id': '42', 'type': 'if_statement', 'children': ['43', '56']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '55'], 'value': '>'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fabs'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '54'], 'value': '-'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'weight'}; {'id': '54', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '55', 'type': 'float', 'children': [], 'value': '1E-7'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'raise_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '%'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'Weights do not sum to 1.0 in %s'"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'attr_name'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'data_tuple'}; {'id': '67', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '68', 'type': 'for_statement', 'children': ['69', '72', '78']}; {'id': '69', 'type': 'pattern_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'iloc'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'Value'"}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'data_tuple'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'tuple', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'weight'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'iloc'}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'data_tuple'}
Converts a list of values and corresponding weights to a tuple of values
def RV_com1(self): return self.RV * (self.M2 / (self.M1 + self.M2))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'RV_com1'}; {'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': 'binary_operator', 'children': ['8', '11'], 'value': '*'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'RV'}; {'id': '11', 'type': '()', 'children': ['12']}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '16'], 'value': '/'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'M2'}; {'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': 'M1'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'M2'}
RVs of star 1 relative to center-of-mass
def _create_xml_node(cls): try: xml_map = cls._xml_map except AttributeError: raise ValueError("This model has no XML definition") return _create_xml_node( xml_map.get('name', cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_xml_node'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'block', 'children': ['6', '22']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '14']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'xml_map'}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_xml_map'}; {'id': '14', 'type': 'except_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'raise_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"This model has no XML definition"'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_create_xml_node'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '35', '42']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'xml_map'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'xml_map'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': '"prefix"'}; {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'xml_map'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"ns"'}; {'id': '48', 'type': 'None', 'children': []}
Create XML node from "_xml_map".
def subst_quoted_strings(sql, params): parts = sql.split('@') params_dont_match = "number of parameters doesn' match the transformed query" assert len(parts) == len(params) + 1, params_dont_match out = [] for i, param in enumerate(params): out.append(parts[i]) out.append("'%s'" % param.replace('\\', '\\\\').replace("\'", "\\\'")) out.append(parts[-1]) return ''.join(out)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'subst_quoted_strings'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '20', '33', '37', '76', '86']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'@'"}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'params_dont_match'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"number of parameters doesn\' match the transformed query"'}; {'id': '20', 'type': 'assert_statement', 'children': ['21', '32']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '26'], 'value': '=='}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '31'], 'value': '+'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'params_dont_match'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '36', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '37', 'type': 'for_statement', 'children': ['38', '41', '45']}; {'id': '38', 'type': 'pattern_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '45', 'type': 'block', 'children': ['46', '55']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}; {'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': 'out'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '%'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"\'%s\'"'}; {'id': '63', 'type': 'call', 'children': ['64', '73']}; {'id': '64', 'type': 'attribute', 'children': ['65', '72']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'\\\\'"}; {'id': '71', 'type': 'string', 'children': [], 'value': "'\\\\\\\\'"}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"\\\'"'}; {'id': '75', 'type': 'string', 'children': [], 'value': '"\\\\\\\'"'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'parts'}; {'id': '84', 'type': 'unary_operator', 'children': ['85'], 'value': '-'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'string', 'children': [], 'value': "''"}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'out'}
Reverse operation to mark_quoted_strings - substitutes '@' by params.
def check_path(file_path): directory = os.path.dirname(file_path) if directory != '': if not os.path.exists(directory): os.makedirs(directory, 0o775)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '5', 'type': 'block', 'children': ['6', '17']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': '!='}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '20', 'type': 'string', 'children': [], 'value': "''"}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'if_statement', 'children': ['23', '32']}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'makedirs'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0o775'}
Checks if the directories for this path exist, and creates them in case.
def value_for_keypath(obj, path): val = obj for part in path.split('.'): match = re.match(list_index_re, part) if match is not None: val = _extract(val, match.group(1)) if not isinstance(val, list) and not isinstance(val, tuple): raise TypeError('expected list/tuple') index = int(match.group(2)) val = val[index] else: val = _extract(val, part) if val is None: return None return val
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'value_for_keypath'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '103']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '19']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '19', 'type': 'block', 'children': ['20', '30', '96']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'list_index_re'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '34', '86']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': 'is not'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35', '48', '68', '80']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_extract'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'val'}; {'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': 'group'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '62']}; {'id': '49', 'type': 'boolean_operator', 'children': ['50', '56'], 'value': 'and'}; {'id': '50', 'type': 'not_operator', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '56', 'type': 'not_operator', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'raise_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'expected list/tuple'"}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '86', 'type': 'else_clause', 'children': ['87']}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_extract'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'part'}; {'id': '96', 'type': 'if_statement', 'children': ['97', '100']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': 'is'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '99', 'type': 'None', 'children': []}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'return_statement', 'children': ['102']}; {'id': '102', 'type': 'None', 'children': []}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'val'}
Get value from walking key path with start object obj.
def del_big_nodes(self, grater_than=215): G = self._graph it = G.nodes_iter() node_paths = [] node_names = [] del_nodes = [] summe = 1 count = 1 for node in it: l = len(G[node]) if l > grater_than: del_nodes.append(node) continue summe += l node_names.append(node) node_paths.append(l) count += 1 for node in del_nodes: G.remove_node(node) if node > 1000000000: self.valid_user.pop(node) print("Nodes deleted: {}".format(len(del_nodes)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'del_big_nodes'}; {'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': 'grater_than'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '215'}; {'id': '8', 'type': 'block', 'children': ['9', '15', '23', '27', '31', '35', '39', '43', '91', '116']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_graph'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'nodes_iter'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'node_paths'}; {'id': '26', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'node_names'}; {'id': '30', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'del_nodes'}; {'id': '34', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'summe'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '43', 'type': 'for_statement', 'children': ['44', '45', '46']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '46', 'type': 'block', 'children': ['47', '56', '69', '73', '80', '87']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '60']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '59'], 'value': '>'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'grater_than'}; {'id': '60', 'type': 'block', 'children': ['61', '68']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'del_nodes'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '68', 'type': 'continue_statement', 'children': []}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'augmented_assignment', 'children': ['71', '72'], 'value': '+='}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'summe'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'node_names'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'node'}; {'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': 'node_paths'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'augmented_assignment', 'children': ['89', '90'], 'value': '+='}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '91', 'type': 'for_statement', 'children': ['92', '93', '94']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'del_nodes'}; {'id': '94', 'type': 'block', 'children': ['95', '102']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'G'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'remove_node'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '106']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '105'], 'value': '>'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '1000000000'}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '114']}; {'id': '109', 'type': 'attribute', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'valid_user'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'string', 'children': [], 'value': '"Nodes deleted: {}"'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'del_nodes'}
Delete big nodes with many connections from the graph.
def _kpost(url, data): headers = {"Content-Type": "application/json"} log.trace("url is: %s, data is: %s", url, data) ret = http.query(url, method='POST', header_dict=headers, data=salt.utils.json.dumps(data)) if ret.get('error'): return ret else: return salt.utils.json.loads(ret.get('body'))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_kpost'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '23', '50']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '10', 'type': 'dictionary', 'children': ['11']}; {'id': '11', 'type': 'pair', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"Content-Type"'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"application/json"'}; {'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': 'trace'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21', '22']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"url is: %s, data is: %s"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'http'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '35', '38']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'POST'"}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'header_dict'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '40', 'type': 'call', 'children': ['41', '48']}; {'id': '41', 'type': 'attribute', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '57', '60']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'error'"}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '60', 'type': 'else_clause', 'children': ['61']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '71']}; {'id': '64', 'type': 'attribute', 'children': ['65', '70']}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'body'"}
create any object in kubernetes based on URL
def parse_datetime(dt_str, format): t = time.strptime(dt_str, format) return datetime(t[0], t[1], t[2], t[3], t[4], t[5], t[6], pytz.UTC)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_datetime'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dt_str'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'strptime'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dt_str'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24', '27', '30', '33', '36', '39', '42']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'pytz'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'UTC'}
Create a timezone-aware datetime object from a datetime string.
def api_run_get(run_id): data = current_app.config["data"] run = data.get_run_dao().get(run_id) records_total = 1 if run is not None else 0 if records_total == 0: return Response( render_template( "api/error.js", error_code=404, error_message="Run %s not found." % run_id), status=404, mimetype="application/json") records_filtered = records_total return Response(render_template("api/runs.js", runs=[run], draw=1, recordsTotal=records_total, recordsFiltered=records_filtered, full_object=True), mimetype="application/json")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'api_run_get'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '27', '36', '63', '67']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'subscript', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"data"'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '17', 'type': 'call', 'children': ['18', '25']}; {'id': '18', 'type': 'attribute', 'children': ['19', '24']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'get_run_dao'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'records_total'}; {'id': '30', 'type': 'conditional_expression', 'children': ['31', '32', '35'], 'value': 'if'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'is not'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '=='}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'records_total'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '57', '60']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'render_template'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49', '52']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"api/error.js"'}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'error_code'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '404'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'error_message'}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '%'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"Run %s not found."'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '404'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'mimetype'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"application/json"'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'records_filtered'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'records_total'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '91']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'render_template'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75', '79', '82', '85', '88']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"api/runs.js"'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'runs'}; {'id': '77', 'type': 'list', 'children': ['78'], 'value': '[run]'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '79', 'type': 'keyword_argument', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'draw'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'keyword_argument', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'recordsTotal'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'records_total'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'recordsFiltered'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'records_filtered'}; {'id': '88', 'type': 'keyword_argument', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'full_object'}; {'id': '90', 'type': 'True', 'children': []}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'mimetype'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"application/json"'}
Return a single run as a JSON object.
def line_up_with_epoch(self): if self.parent.notes.annot is None: error_dialog = QErrorMessage() error_dialog.setWindowTitle('Error moving to epoch') error_dialog.showMessage('No score file loaded') error_dialog.exec() return new_window_start = self.parent.notes.annot.get_epoch_start( self.parent.value('window_start')) self.parent.overview.update_position(new_window_start)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'line_up_with_epoch'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '44', '66']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '15'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'annot'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '23', '30', '37', '43']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'error_dialog'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'QErrorMessage'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'error_dialog'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'setWindowTitle'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'Error moving to epoch'"}; {'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': 'error_dialog'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'showMessage'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'No score file loaded'"}; {'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': 'error_dialog'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'exec'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'return_statement', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'new_window_start'}; {'id': '47', 'type': 'call', 'children': ['48', '57']}; {'id': '48', 'type': 'attribute', 'children': ['49', '56']}; {'id': '49', 'type': 'attribute', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'annot'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'get_epoch_start'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'string', 'children': [], 'value': "'window_start'"}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '75']}; {'id': '68', 'type': 'attribute', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'overview'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'update_position'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'new_window_start'}
Go to the start of the present epoch.
def read_hdf5_segmentlist(h5f, path=None, gpstype=LIGOTimeGPS, **kwargs): dataset = io_hdf5.find_dataset(h5f, path=path) segtable = Table.read(dataset, format='hdf5', **kwargs) out = SegmentList() for row in segtable: start = LIGOTimeGPS(int(row['start_time']), int(row['start_time_ns'])) end = LIGOTimeGPS(int(row['end_time']), int(row['end_time_ns'])) if gpstype is LIGOTimeGPS: out.append(Segment(start, end)) else: out.append(Segment(gpstype(start), gpstype(end))) return out
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_hdf5_segmentlist'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'h5f'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'gpstype'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'LIGOTimeGPS'}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '13', 'type': 'block', 'children': ['14', '26', '40', '46', '121']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'io_hdf5'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'find_dataset'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'h5f'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'segtable'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35', '38']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'hdf5'"}; {'id': '38', 'type': 'dictionary_splat', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'SegmentList'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'for_statement', 'children': ['47', '48', '49']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'segtable'}; {'id': '49', 'type': 'block', 'children': ['50', '68', '86']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'LIGOTimeGPS'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '62']}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'start_time'"}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'start_time_ns'"}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'LIGOTimeGPS'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '80']}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'end_time'"}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'end_time_ns'"}; {'id': '86', 'type': 'if_statement', 'children': ['87', '90', '102']}; {'id': '87', 'type': 'comparison_operator', 'children': ['88', '89'], 'value': 'is'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'gpstype'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'LIGOTimeGPS'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'Segment'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '102', 'type': 'else_clause', 'children': ['103']}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'call', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'Segment'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '117']}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'gpstype'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'gpstype'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '121', 'type': 'return_statement', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'out'}
Read a `SegmentList` object from an HDF5 file or group.
def _traverse_unobserved(stream,negative_filter,of): observed = set() for line in stream: name = PacBioReadName(_nameprog.match(line).group(1)) if name.get_molecule() not in negative_filter: of.write(line) observed.add(name.get_molecule()) return negative_filter|observed
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_traverse_unobserved'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'negative_filter'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'of'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '62']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'observed'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '17']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '17', 'type': 'block', 'children': ['18', '35', '51']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'PacBioReadName'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '33']}; {'id': '25', 'type': 'attribute', 'children': ['26', '32']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_nameprog'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '43']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '42'], 'value': 'not in'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'get_molecule'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'negative_filter'}; {'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': 'of'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'line'}; {'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': 'observed'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'get_molecule'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '|'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'negative_filter'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'observed'}
Go through a stream and print out anything not in observed set
def _add_nat(self): if is_period_dtype(self): raise TypeError('Cannot add {cls} and {typ}' .format(cls=type(self).__name__, typ=type(NaT).__name__)) result = np.zeros(len(self), dtype=np.int64) result.fill(iNaT) return type(self)(result, dtype=self.dtype, freq=None)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_nat'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '37', '54', '61']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'is_period_dtype'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'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': 'TypeError'}; {'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': "'Cannot add {cls} and {typ}'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '29']}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '23', 'type': 'attribute', 'children': ['24', '28']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'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': 'NaT'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '49']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'int64'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'fill'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'iNaT'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '67']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '74']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'freq'}; {'id': '76', 'type': 'None', 'children': []}
Add pd.NaT to self
def _determine_scaling_policies(scaling_policies, scaling_policies_from_pillar): pillar_scaling_policies = copy.deepcopy( __salt__['config.option'](scaling_policies_from_pillar, {}) ) if not scaling_policies and pillar_scaling_policies: scaling_policies = pillar_scaling_policies return scaling_policies
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_determine_scaling_policies'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'scaling_policies'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scaling_policies_from_pillar'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '32']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pillar_scaling_policies'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__salt__'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'config.option'"}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'scaling_policies_from_pillar'}; {'id': '21', 'type': 'dictionary', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '27']}; {'id': '23', 'type': 'boolean_operator', 'children': ['24', '26'], 'value': 'and'}; {'id': '24', 'type': 'not_operator', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'scaling_policies'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pillar_scaling_policies'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'scaling_policies'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pillar_scaling_policies'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'scaling_policies'}
helper method for present. ensure that scaling_policies are set
def ensure_connected(self): if not self.is_connected(): if not self._auto_connect: raise DBALConnectionError.connection_closed() self.connect()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ensure_connected'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'is_connected'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '26']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '19']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_auto_connect'}; {'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': 'DBALConnectionError'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'connection_closed'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '31', 'type': 'argument_list', 'children': []}
Ensures database connection is still open.
def RunOnce(self): from grr_response_server.gui import gui_plugins if config.CONFIG.Get("AdminUI.django_secret_key", None): logging.warning( "The AdminUI.django_secret_key option has been deprecated, " "please use AdminUI.csrf_secret_key instead.")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'RunOnce'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'dotted_name', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'grr_response_server'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'gui'}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'gui_plugins'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '22']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'CONFIG'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Get'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"AdminUI.django_secret_key"'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'concatenated_string', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"The AdminUI.django_secret_key option has been deprecated, "'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"please use AdminUI.csrf_secret_key instead."'}
Import the plugins once only.
def read_sheets(archive): xml_source = archive.read(ARC_WORKBOOK) tree = fromstring(xml_source) for element in safe_iterator(tree, '{%s}sheet' % SHEET_MAIN_NS): attrib = element.attrib attrib['id'] = attrib["{%s}id" % REL_NS] del attrib["{%s}id" % REL_NS] if attrib['id']: yield attrib
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_sheets'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'archive'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '22']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'xml_source'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'archive'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ARC_WORKBOOK'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'fromstring'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'xml_source'}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '31']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'safe_iterator'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '%'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'{%s}sheet'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'SHEET_MAIN_NS'}; {'id': '31', 'type': 'block', 'children': ['32', '38', '48', '54']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '43']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '%'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"{%s}id"'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'REL_NS'}; {'id': '48', 'type': 'delete_statement', 'children': ['49']}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '%'}; {'id': '52', 'type': 'string', 'children': [], 'value': '"{%s}id"'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'REL_NS'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '58']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'yield', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'attrib'}
Read worksheet titles and ids for a workbook
def find_permission(self, name): return ( self.get_session.query(self.permission_model).filter_by(name=name).first() )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_permission'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': '()', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '29']}; {'id': '10', 'type': 'attribute', 'children': ['11', '28']}; {'id': '11', 'type': 'call', 'children': ['12', '24']}; {'id': '12', 'type': 'attribute', 'children': ['13', '23']}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'get_session'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'permission_model'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filter_by'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '29', 'type': 'argument_list', 'children': []}
Finds and returns a Permission by name
def toy_linear_1d_classification(seed=default_seed): def sample_class(f): p = 1. / (1. + np.exp(-f)) c = np.random.binomial(1, p) c = np.where(c, 1, -1) return c np.random.seed(seed=seed) x1 = np.random.normal(-3, 5, 20) x2 = np.random.normal(3, 5, 20) X = (np.r_[x1, x2])[:, None] return {'X': X, 'Y': sample_class(2.*X), 'F': 2.*X, 'covariates' : ['X'], 'response': [discrete({'positive': 1, 'negative': -1})],'seed' : seed}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'toy_linear_1d_classification'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'default_seed'}; {'id': '7', 'type': 'block', 'children': ['8', '54', '65', '79', '92', '106']}; {'id': '8', 'type': 'function_definition', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'function_name', 'children': [], 'value': 'sample_class'}; {'id': '10', 'type': 'parameters', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '12', 'type': 'block', 'children': ['13', '28', '40', '52']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '/'}; {'id': '17', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '18', 'type': '()', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '+'}; {'id': '20', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'exp'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'unary_operator', 'children': ['27'], 'value': '-'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'binomial'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49', '50']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '50', 'type': 'unary_operator', 'children': ['51'], 'value': '-'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'c'}; {'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': 'np'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'seed'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'x1'}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'normal'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '77', '78']}; {'id': '75', 'type': 'unary_operator', 'children': ['76'], 'value': '-'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'x2'}; {'id': '82', 'type': 'call', 'children': ['83', '88']}; {'id': '83', 'type': 'attribute', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'normal'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90', '91']}; {'id': '89', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '95', 'type': 'subscript', 'children': ['96', '103', '105']}; {'id': '96', 'type': '()', 'children': ['97']}; {'id': '97', 'type': 'subscript', 'children': ['98', '101', '102']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'r_'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'x1'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'x2'}; {'id': '103', 'type': 'slice', 'children': ['104']}; {'id': '104', 'type': 'colon', 'children': []}; {'id': '105', 'type': 'None', 'children': []}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'dictionary', 'children': ['108', '111', '119', '124', '128', '142']}; {'id': '108', 'type': 'pair', 'children': ['109', '110']}; {'id': '109', 'type': 'string', 'children': [], 'value': "'X'"}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '111', 'type': 'pair', 'children': ['112', '113']}; {'id': '112', 'type': 'string', 'children': [], 'value': "'Y'"}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'sample_class'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'binary_operator', 'children': ['117', '118'], 'value': '*'}; {'id': '117', 'type': 'float', 'children': [], 'value': '2.'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '119', 'type': 'pair', 'children': ['120', '121']}; {'id': '120', 'type': 'string', 'children': [], 'value': "'F'"}; {'id': '121', 'type': 'binary_operator', 'children': ['122', '123'], 'value': '*'}; {'id': '122', 'type': 'float', 'children': [], 'value': '2.'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '124', 'type': 'pair', 'children': ['125', '126']}; {'id': '125', 'type': 'string', 'children': [], 'value': "'covariates'"}; {'id': '126', 'type': 'list', 'children': ['127'], 'value': "['X']"}; {'id': '127', 'type': 'string', 'children': [], 'value': "'X'"}; {'id': '128', 'type': 'pair', 'children': ['129', '130']}; {'id': '129', 'type': 'string', 'children': [], 'value': "'response'"}; {'id': '130', 'type': 'list', 'children': ['131'], 'value': "[discrete({'positive': 1, 'negative': -1})]"}; {'id': '131', 'type': 'call', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'discrete'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'dictionary', 'children': ['135', '138']}; {'id': '135', 'type': 'pair', 'children': ['136', '137']}; {'id': '136', 'type': 'string', 'children': [], 'value': "'positive'"}; {'id': '137', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '138', 'type': 'pair', 'children': ['139', '140']}; {'id': '139', 'type': 'string', 'children': [], 'value': "'negative'"}; {'id': '140', 'type': 'unary_operator', 'children': ['141'], 'value': '-'}; {'id': '141', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '142', 'type': 'pair', 'children': ['143', '144']}; {'id': '143', 'type': 'string', 'children': [], 'value': "'seed'"}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'seed'}
Simple classification data in one dimension for illustrating models.
def exec_before_request_actions(actions, **kwargs): groups = ("before", "before_" + flask.request.method.lower()) return execute_actions(actions, limit_groups=groups, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exec_before_request_actions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '24']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '11', 'type': 'tuple', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"before"'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '15'], 'value': '+'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"before_"'}; {'id': '15', 'type': 'call', 'children': ['16', '23']}; {'id': '16', 'type': 'attribute', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'flask'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'execute_actions'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'limit_groups'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '32', 'type': 'dictionary_splat', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Execute actions in the "before" and "before_METHOD" groups
def limit(self, limit: int) -> "QuerySet": queryset = self._clone() queryset._limit = limit return queryset
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'limit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': '"QuerySet"'}; {'id': '11', 'type': 'block', 'children': ['12', '20', '26']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_clone'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_limit'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'queryset'}
Limits QuerySet to given length.
def grandparent_path(self): return os.path.basename(os.path.join(self.path, '../..'))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'grandparent_path'}; {'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': 'basename'}; {'id': '13', 'type': 'argument_list', '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': 'os'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'../..'"}
return grandparent's path string
def create(self, client_id, title, unsubscribe_page, confirmed_opt_in, confirmation_success_page, unsubscribe_setting="AllClientLists"): body = { "Title": title, "UnsubscribePage": unsubscribe_page, "ConfirmedOptIn": confirmed_opt_in, "ConfirmationSuccessPage": confirmation_success_page, "UnsubscribeSetting": unsubscribe_setting} response = self._post("/lists/%s.json" % client_id, json.dumps(body)) self.list_id = json_to_py(response) return self.list_id
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'unsubscribe_page'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'confirmed_opt_in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'confirmation_success_page'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'unsubscribe_setting'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"AllClientLists"'}; {'id': '13', 'type': 'block', 'children': ['14', '33', '50', '59']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '17', 'type': 'dictionary', 'children': ['18', '21', '24', '27', '30']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"Title"'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"UnsubscribePage"'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'unsubscribe_page'}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"ConfirmedOptIn"'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'confirmed_opt_in'}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"ConfirmationSuccessPage"'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'confirmation_success_page'}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"UnsubscribeSetting"'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'unsubscribe_setting'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_post'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '43'], 'value': '%'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"/lists/%s.json"'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'list_id'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'json_to_py'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '59', 'type': 'return_statement', 'children': ['60']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'list_id'}
Creates a new list for a client.
def _stop_actions(self): Global.LOGGER.info("stopping actions") list(map(lambda x: x.stop(), self.actions)) Global.LOGGER.info("actions stopped")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_stop_actions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '33']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Global'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'string', 'children': [], 'value': '"stopping actions"'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '30']}; {'id': '22', 'type': 'lambda', 'children': ['23', '25']}; {'id': '23', 'type': 'lambda_parameters', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Global'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': '"actions stopped"'}
Stop all the actions
def activate_right(self, token): watchers.MATCHER.debug( "Node <%s> activated right with token %r", self, token) return self._activate_right(token.copy())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'activate_right'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '6', 'type': 'block', 'children': ['7', '18']}; {'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': 'watchers'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'MATCHER'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '17']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"Node <%s> activated right with token %r"'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_activate_right'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '28', 'type': 'argument_list', 'children': []}
Make a copy of the received token and call `_activate_right`.
def scan(self, string): return list(self._scanner_to_matches(self.pattern.scanner(string), self.run))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scan'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_scanner_to_matches'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '24']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'scanner'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'run'}
Like findall, but also returning matching start and end string locations
def filter_delete(self, id): id = self.__unpack_id(id) url = '/api/v1/filters/{0}'.format(str(id)) self.__api_request('DELETE', url)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_delete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '28']}; {'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': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '__unpack_id'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'/api/v1/filters/{0}'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'id'}; {'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': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '__api_request'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'DELETE'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'url'}
Deletes the filter with the given `id`.
def _get_caller_supplement(caller, data): if caller == "mutect": icaller = tz.get_in(["config", "algorithm", "indelcaller"], data) if icaller: caller = "%s/%s" % (caller, icaller) return caller
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_caller_supplement'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'caller'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7', '36']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '=='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'caller'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"mutect"'}; {'id': '11', 'type': 'block', 'children': ['12', '25']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'icaller'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_in'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '24']}; {'id': '20', 'type': 'list', 'children': ['21', '22', '23'], 'value': '["config", "algorithm", "indelcaller"]'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"config"'}; {'id': '22', 'type': 'string', 'children': [], 'value': '"algorithm"'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"indelcaller"'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'icaller'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'caller'}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '%'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"%s/%s"'}; {'id': '33', 'type': 'tuple', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'caller'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'icaller'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'caller'}
Some callers like MuTect incorporate a second caller for indels.
def _create_optObject(self, **kwargs): optimizer = kwargs.get('optimizer', self.config['optimizer']['optimizer']) if optimizer.upper() == 'MINUIT': optObject = pyLike.Minuit(self.like.logLike) elif optimizer.upper() == 'NEWMINUIT': optObject = pyLike.NewMinuit(self.like.logLike) else: optFactory = pyLike.OptimizerFactory_instance() optObject = optFactory.create(str(optimizer), self.like.logLike) return optObject
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_optObject'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '24', '95']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'optimizer'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'optimizer'"}; {'id': '17', 'type': 'subscript', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'optimizer'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'optimizer'"}; {'id': '24', 'type': 'if_statement', 'children': ['25', '32', '46', '68']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '31'], 'value': '=='}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'optimizer'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'string', 'children': [], 'value': "'MINUIT'"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'optObject'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'pyLike'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Minuit'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'like'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'logLike'}; {'id': '46', 'type': 'elif_clause', 'children': ['47', '54']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '53'], 'value': '=='}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'optimizer'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'id': '53', 'type': 'string', 'children': [], 'value': "'NEWMINUIT'"}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'optObject'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'pyLike'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'NewMinuit'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'like'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'logLike'}; {'id': '68', 'type': 'else_clause', 'children': ['69']}; {'id': '69', 'type': 'block', 'children': ['70', '78']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'optFactory'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'pyLike'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'OptimizerFactory_instance'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'optObject'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'optFactory'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'create'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '90']}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'optimizer'}; {'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': 'like'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'logLike'}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'optObject'}
Make MINUIT or NewMinuit type optimizer object
def load_medium(self, model): media = self.config.get("medium") if media is None: return definitions = media.get("definitions") if definitions is None or len(definitions) == 0: return path = self.get_path(media, join("data", "experimental", "media")) for medium_id, medium in iteritems(definitions): if medium is None: medium = dict() filename = medium.get("filename") if filename is None: filename = join(path, "{}.csv".format(medium_id)) elif not isabs(filename): filename = join(path, filename) tmp = Medium(identifier=medium_id, obj=medium, filename=filename) tmp.load() tmp.validate(model) self.media[medium_id] = tmp
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_medium'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '24', '33', '46', '61']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'media'}; {'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': 'config'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"medium"'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '22']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'is'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'media'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'definitions'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'media'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"definitions"'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '44']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '38'], 'value': 'or'}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'is'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'definitions'}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '43'], 'value': '=='}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'definitions'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'return_statement', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'get_path'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'media'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59', '60']}; {'id': '58', 'type': 'string', 'children': [], 'value': '"data"'}; {'id': '59', 'type': 'string', 'children': [], 'value': '"experimental"'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"media"'}; {'id': '61', 'type': 'for_statement', 'children': ['62', '65', '69']}; {'id': '62', 'type': 'pattern_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'medium_id'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'medium'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'definitions'}; {'id': '69', 'type': 'block', 'children': ['70', '81', '90', '123', '138', '144', '151']}; {'id': '70', 'type': 'if_statement', 'children': ['71', '74']}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'is'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'medium'}; {'id': '73', 'type': 'None', 'children': []}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'medium'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'medium'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'string', 'children': [], 'value': '"filename"'}; {'id': '90', 'type': 'if_statement', 'children': ['91', '94', '108']}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '93'], 'value': 'is'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '93', 'type': 'None', 'children': []}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '98', 'type': 'call', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'string', 'children': [], 'value': '"{}.csv"'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'medium_id'}; {'id': '108', 'type': 'elif_clause', 'children': ['109', '114']}; {'id': '109', 'type': 'not_operator', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'isabs'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '118', 'type': 'call', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '120', 'type': 'argument_list', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'tmp'}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'Medium'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '132', '135']}; {'id': '129', 'type': 'keyword_argument', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'medium_id'}; {'id': '132', 'type': 'keyword_argument', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'medium'}; {'id': '135', 'type': 'keyword_argument', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'call', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'tmp'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '143', 'type': 'argument_list', 'children': []}; {'id': '144', 'type': 'expression_statement', 'children': ['145']}; {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'tmp'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'validate'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '158']}; {'id': '153', 'type': 'subscript', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'media'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'medium_id'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'tmp'}
Load and validate all media.
def _find_topics_with_wrong_rp(topics, zk, default_min_isr): topics_with_wrong_rf = [] for topic_name, partitions in topics.items(): min_isr = get_min_isr(zk, topic_name) or default_min_isr replication_factor = len(partitions[0].replicas) if replication_factor >= min_isr + 1: continue topics_with_wrong_rf.append({ 'replication_factor': replication_factor, 'min_isr': min_isr, 'topic': topic_name, }) return topics_with_wrong_rf
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_topics_with_wrong_rp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'topics'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'zk'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'default_min_isr'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '67']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'topics_with_wrong_rf'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'for_statement', 'children': ['13', '16', '21']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'topic_name'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'partitions'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'topics'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '32', '43', '51']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'min_isr'}; {'id': '25', 'type': 'boolean_operator', 'children': ['26', '31'], 'value': 'or'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get_min_isr'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'zk'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'topic_name'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'default_min_isr'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'replication_factor'}; {'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', '42']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'partitions'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'replicas'}; {'id': '43', 'type': 'if_statement', 'children': ['44', '49']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': '>='}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'replication_factor'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '+'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'min_isr'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'continue_statement', 'children': []}; {'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': 'topics_with_wrong_rf'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'dictionary', 'children': ['58', '61', '64']}; {'id': '58', 'type': 'pair', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'replication_factor'"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'replication_factor'}; {'id': '61', 'type': 'pair', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'min_isr'"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'min_isr'}; {'id': '64', 'type': 'pair', 'children': ['65', '66']}; {'id': '65', 'type': 'string', 'children': [], 'value': "'topic'"}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'topic_name'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'topics_with_wrong_rf'}
Returns topics with wrong replication factor.
def handle_subscribe(self, request): ret = self._tree.handle_subscribe(request, request.path[1:]) self._subscription_keys[request.generate_key()] = request return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_subscribe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'block', 'children': ['7', '25', '37']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'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': '_tree'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'handle_subscribe'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'slice', 'children': ['23', '24']}; {'id': '23', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '24', 'type': 'colon', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '36']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_subscription_keys'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'generate_key'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ret'}
Handle a Subscribe request from outside. Called with lock taken
def validate_regexp(ctx, param, value): if value: try: value = re.compile(value) except ValueError: raise click.BadParameter('invalid regular expression.') return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_regexp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctx'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8', '32']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'try_statement', 'children': ['12', '22']}; {'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': 'value'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'compile'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '22', 'type': 'except_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'raise_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'BadParameter'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'invalid regular expression.'"}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'value'}
Validate and compile regular expression.
def count_terms(geneset, assoc, obo_dag): term_cnt = Counter() for gene in (g for g in geneset if g in assoc): for goid in assoc[gene]: if goid in obo_dag: term_cnt[obo_dag[goid].id] += 1 return term_cnt
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count_terms'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'geneset'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'assoc'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'obo_dag'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '47']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'term_cnt'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Counter'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '25']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'gene'}; {'id': '16', 'type': 'generator_expression', 'children': ['17', '18', '21']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '18', 'type': 'for_in_clause', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'geneset'}; {'id': '21', 'type': 'if_clause', 'children': ['22']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': 'in'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'assoc'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '31']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'goid'}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'assoc'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'gene'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'in'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'goid'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'obo_dag'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'augmented_assignment', 'children': ['39', '46'], 'value': '+='}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'term_cnt'}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'obo_dag'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'goid'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'term_cnt'}
count the number of terms in the study group
def __get_ac_row(self, ac: model.AssetClass) -> AssetAllocationViewModel: view_model = AssetAllocationViewModel() view_model.depth = ac.depth view_model.name = ac.name view_model.set_allocation = ac.allocation view_model.curr_allocation = ac.curr_alloc view_model.diff_allocation = ac.alloc_diff view_model.alloc_diff_perc = ac.alloc_diff_perc view_model.curr_value = ac.curr_value view_model.set_value = ac.alloc_value view_model.diff_value = ac.value_diff return view_model
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_ac_row'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'AssetClass'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'AssetAllocationViewModel'}; {'id': '13', 'type': 'block', 'children': ['14', '20', '28', '36', '44', '52', '60', '68', '76', '84', '92']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'view_model'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'AssetAllocationViewModel'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'view_model'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'depth'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'depth'}; {'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': 'view_model'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'name'}; {'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': 'view_model'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'set_allocation'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'allocation'}; {'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': 'view_model'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'curr_allocation'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'curr_alloc'}; {'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': 'view_model'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'diff_allocation'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'alloc_diff'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'view_model'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'alloc_diff_perc'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'alloc_diff_perc'}; {'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': 'view_model'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'curr_value'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'curr_value'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'view_model'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'set_value'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'alloc_value'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'view_model'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'diff_value'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'ac'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'value_diff'}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'view_model'}
Formats one Asset Class record
def parse_diff_filenames(diff_files): files = [] for line in diff_files.splitlines(): line = line.strip() fn = re.findall('[^ ]+\s+(.*.py)', line) if fn and not line.startswith('?'): files.append(fn[0]) return files
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_diff_filenames'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'diff_files'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '56']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '17']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'diff_files'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '26', '36']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'findall'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'[^ ]+\\s+(.*.py)'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '46']}; {'id': '37', 'type': 'boolean_operator', 'children': ['38', '39'], 'value': 'and'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'?'"}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'files'}
Parse the output of filenames_diff_cmd.
def pbar(iter, desc='', **kwargs): return tqdm( iter, desc=('<' + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) + '> ' + desc), dynamic_ncols=True, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pbar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '7', 'type': 'string', 'children': [], 'value': "''"}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'return_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'tqdm'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '38', '41']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '18', 'type': '()', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '37'], 'value': '+'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '36'], 'value': '+'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '+'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'<'"}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '34']}; {'id': '27', 'type': 'attribute', 'children': ['28', '33']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'now'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'strftime'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"%Y-%m-%d %H:%M:%S"'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'> '"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dynamic_ncols'}; {'id': '40', 'type': 'True', 'children': []}; {'id': '41', 'type': 'dictionary_splat', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Wrapper for `tqdm` progress bar.
def release_all(self, callback: Callable[[str, Any, Any], None]): self._all_callbacks.remove(callback)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'release_all'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'callback'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'generic_type', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Callable'}; {'id': '10', 'type': 'type_parameter', 'children': ['11', '16']}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'list', 'children': ['13', '14', '15'], 'value': '[str, Any, Any]'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Any'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Any'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'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': '_all_callbacks'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'callback'}
Releases callback from all keys changes
def expand_dates(df, columns=[]): columns = df.columns.intersection(columns) df2 = df.reindex(columns=set(df.columns).difference(columns)) for column in columns: df2[column + '_year'] = df[column].apply(lambda x: x.year) df2[column + '_month'] = df[column].apply(lambda x: x.month) df2[column + '_day'] = df[column].apply(lambda x: x.day) return df2
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expand_dates'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '7', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '8', 'type': 'block', 'children': ['9', '20', '41', '105']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'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': 'df'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'intersection'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'df2'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'reindex'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '30', 'type': 'call', 'children': ['31', '39']}; {'id': '31', 'type': 'attribute', 'children': ['32', '38']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'difference'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '41', 'type': 'for_statement', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '44', 'type': 'block', 'children': ['45', '65', '85']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '52']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'df2'}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '+'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'_year'"}; {'id': '52', 'type': 'call', 'children': ['53', '58']}; {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'apply'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'lambda', 'children': ['60', '62']}; {'id': '60', 'type': 'lambda_parameters', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '72']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'df2'}; {'id': '69', 'type': 'binary_operator', 'children': ['70', '71'], 'value': '+'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'_month'"}; {'id': '72', 'type': 'call', 'children': ['73', '78']}; {'id': '73', 'type': 'attribute', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'apply'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'lambda', 'children': ['80', '82']}; {'id': '80', 'type': 'lambda_parameters', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '92']}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'df2'}; {'id': '89', 'type': 'binary_operator', 'children': ['90', '91'], 'value': '+'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'_day'"}; {'id': '92', 'type': 'call', 'children': ['93', '98']}; {'id': '93', 'type': 'attribute', 'children': ['94', '97']}; {'id': '94', 'type': 'subscript', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'apply'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'lambda', 'children': ['100', '102']}; {'id': '100', 'type': 'lambda_parameters', 'children': ['101']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'df2'}
generate year, month, day features from specified date features
def merge(self, other): for key, value in other.items(): if key in self and (isinstance(self[key], Compound) and isinstance(value, dict)): self[key].merge(value) else: self[key] = value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '11', '16']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '36', '46']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '22'], 'value': 'and'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'in'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': '()', 'children': ['23']}; {'id': '23', 'type': 'boolean_operator', 'children': ['24', '31'], 'value': 'and'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Compound'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'merge'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'else_clause', 'children': ['47']}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'value'}
Recursively merge tags from another compound.
def check_dir(directory, newly_created_files): header_parse_failures = [] for root, dirs, files in os.walk(directory): for f in files: if f.endswith('.py') and os.path.basename(f) != '__init__.py': filename = os.path.join(root, f) try: check_header(filename, filename in newly_created_files) except HeaderCheckFailure as e: header_parse_failures.append(e.message) return header_parse_failures
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'newly_created_files'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '83']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'header_parse_failures'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '16', '22']}; {'id': '12', 'type': 'pattern_list', 'children': ['13', '14', '15']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dirs'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'if_statement', 'children': ['28', '45']}; {'id': '28', 'type': 'boolean_operator', 'children': ['29', '35'], 'value': 'and'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'.py'"}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '44'], 'value': '!='}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'__init__.py'"}; {'id': '45', 'type': 'block', 'children': ['46', '58']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '58', 'type': 'try_statement', 'children': ['59', '68']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'check_header'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': 'in'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'newly_created_files'}; {'id': '68', 'type': 'except_clause', 'children': ['69', '73']}; {'id': '69', 'type': 'as_pattern', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'HeaderCheckFailure'}; {'id': '71', 'type': 'as_pattern_target', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'header_parse_failures'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '83', 'type': 'return_statement', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'header_parse_failures'}
Returns list of files that fail the check.
def hue_sat_to_cmap(hue, sat): import colorsys hue = float(hue) / 360.0 sat = float(sat) / 100.0 res = [] for val in range(256): hsv_val = float(val) / 255.0 r, g, b = colorsys.hsv_to_rgb(hue, sat, hsv_val) res.append((r, g, b)) return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hue_sat_to_cmap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'hue'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'sat'}; {'id': '6', 'type': 'block', 'children': ['7', '10', '19', '28', '32', '72']}; {'id': '7', 'type': 'import_statement', 'children': ['8']}; {'id': '8', 'type': 'dotted_name', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'colorsys'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'hue'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '18'], 'value': '/'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'hue'}; {'id': '18', 'type': 'float', 'children': [], 'value': '360.0'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sat'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '27'], 'value': '/'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sat'}; {'id': '27', 'type': 'float', 'children': [], 'value': '100.0'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '31', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '38']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'integer', 'children': [], 'value': '256'}; {'id': '38', 'type': 'block', 'children': ['39', '48', '62']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'hsv_val'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '47'], 'value': '/'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '47', 'type': 'float', 'children': [], 'value': '255.0'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '54']}; {'id': '50', 'type': 'pattern_list', 'children': ['51', '52', '53']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'colorsys'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'hsv_to_rgb'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '61']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'hue'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'sat'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'hsv_val'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'tuple', 'children': ['69', '70', '71']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'res'}
Mkae a color map from a hue and saturation value.
def StartFileFetch(self, pathspec, request_data=None): self.state.indexed_pathspecs.append(pathspec) self.state.request_data_list.append(request_data) self._TryToStartNextPathspec()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'StartFileFetch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pathspec'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'request_data'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '21', '32']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '19']}; {'id': '12', 'type': 'attribute', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'indexed_pathspecs'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'pathspec'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '30']}; {'id': '23', 'type': 'attribute', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'request_data_list'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'request_data'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_TryToStartNextPathspec'}; {'id': '37', 'type': 'argument_list', 'children': []}
The entry point for this flow mixin - Schedules new file transfer.
def prune_cached(values): import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): return values cached = [x.strip() for x in open(file_path, 'r').readlines()] output = list() for item in values: hashed = hash_values(item) if hashed in cached: continue output.append(item) return output
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prune_cached'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '5', 'type': 'block', 'children': ['6', '9', '20', '32', '45', '65', '71', '95']}; {'id': '6', 'type': 'import_statement', 'children': ['7']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'config_path'}; {'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': 'os'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'~/.config/blockade'"}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'config_path'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'cache.txt'"}; {'id': '32', 'type': 'if_statement', 'children': ['33', '42']}; {'id': '33', 'type': 'not_operator', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'cached'}; {'id': '48', 'type': 'list_comprehension', 'children': ['49', '54']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '56', 'type': 'call', 'children': ['57', '64']}; {'id': '57', 'type': 'attribute', 'children': ['58', '63']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'file_path'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'readlines'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '70', 'type': 'argument_list', 'children': []}; {'id': '71', 'type': 'for_statement', 'children': ['72', '73', '74']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '74', 'type': 'block', 'children': ['75', '82', '88']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'hashed'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'hash_values'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '82', 'type': 'if_statement', 'children': ['83', '86']}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '85'], 'value': 'in'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'hashed'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'cached'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'continue_statement', 'children': []}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'output'}
Remove the items that have already been cached.
def _swap(self, class1, class2, a): ss1 = self._ss(class1) ss2 = self._ss(class2) tss1 = ss1 + ss2 class1c = copy.copy(class1) class2c = copy.copy(class2) class1c.remove(a) class2c.append(a) ss1 = self._ss(class1c) ss2 = self._ss(class2c) tss2 = ss1 + ss2 if tss1 < tss2: return False else: return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_swap'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'class1'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'class2'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '8', 'type': 'block', 'children': ['9', '18', '27', '33', '42', '51', '58', '65', '74', '83', '89']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ss1'}; {'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': '_ss'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'class1'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ss2'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_ss'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'class2'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'tss1'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '32'], 'value': '+'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ss1'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ss2'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'class1c'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'class1'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'class2c'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'class2'}; {'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': 'class1c'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'class2c'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'ss1'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_ss'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'class1c'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ss2'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_ss'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'class2c'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'tss2'}; {'id': '86', 'type': 'binary_operator', 'children': ['87', '88'], 'value': '+'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'ss1'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'ss2'}; {'id': '89', 'type': 'if_statement', 'children': ['90', '93', '96']}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '92'], 'value': '<'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'tss1'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'tss2'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'False', 'children': []}; {'id': '96', 'type': 'else_clause', 'children': ['97']}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'True', 'children': []}
evaluate cost of moving a from class1 to class2
def attrs(self): return dict((k, v) for k, v in iteritems(self.__dict__) if k is not "sdk")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'attrs'}; {'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': 'dict'}; {'id': '9', 'type': 'generator_expression', 'children': ['10', '13', '23']}; {'id': '10', 'type': 'tuple', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '13', 'type': 'for_in_clause', 'children': ['14', '17']}; {'id': '14', 'type': 'pattern_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '__dict__'}; {'id': '23', 'type': 'if_clause', 'children': ['24']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'is not'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"sdk"'}
Returns a dictionary of the archive's attributes.
def _from_dict(cls, _dict): args = {} if 'contentItems' in _dict: args['content_items'] = [ ContentItem._from_dict(x) for x in (_dict.get('contentItems')) ] else: raise ValueError( 'Required property \'contentItems\' not present in Content JSON' ) return cls(**args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15', '37']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'contentItems'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'content_items'"}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ContentItem'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_from_dict'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'for_in_clause', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '30', 'type': '()', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'contentItems'"}; {'id': '37', 'type': 'else_clause', 'children': ['38']}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'raise_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'string', 'children': [], 'value': "'Required property \\'contentItems\\' not present in Content JSON'"}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'dictionary_splat', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}
Initialize a Content object from a json dictionary.
def checkGeneTreeMatchesSpeciesTree(speciesTree, geneTree, processID): def fn(tree, l): if tree.internal: fn(tree.left, l) fn(tree.right, l) else: l.append(processID(tree.iD)) l = [] fn(speciesTree, l) l2 = [] fn(geneTree, l2) for i in l2: assert i in l
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'checkGeneTreeMatchesSpeciesTree'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'speciesTree'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'geneTree'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'processID'}; {'id': '7', 'type': 'block', 'children': ['8', '49', '53', '59', '63', '69']}; {'id': '8', 'type': 'function_definition', 'children': ['9', '10', '13']}; {'id': '9', 'type': 'function_name', 'children': [], 'value': 'fn'}; {'id': '10', 'type': 'parameters', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18', '35']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'internal'}; {'id': '18', 'type': 'block', 'children': ['19', '27']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '35', 'type': 'else_clause', 'children': ['36']}; {'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': 'l'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'processID'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'iD'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '52', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'speciesTree'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'l2'}; {'id': '62', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'geneTree'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'l2'}; {'id': '69', 'type': 'for_statement', 'children': ['70', '71', '72']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'l2'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'assert_statement', 'children': ['74']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': 'in'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'l'}
Function to check ids in gene tree all match nodes in species tree
def zcr(data): data = np.mean(data, axis=1) count = len(data) countZ = np.sum(np.abs(np.diff(np.sign(data)))) / 2 return (np.float64(countZ) / np.float64(count - 1.0))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zcr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '25', '51']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'mean'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'countZ'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '50'], 'value': '/'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'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': 'np'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'sign'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '60'], 'value': '/'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'float64'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'countZ'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'float64'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '-'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '67', 'type': 'float', 'children': [], 'value': '1.0'}
Computes zero crossing rate of segment
def _methodInTraceback(self, name, traceback): foundMethod = False for frame in self._frames(traceback): this = frame.f_locals.get('self') if this is self and frame.f_code.co_name == name: foundMethod = True break return foundMethod
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_methodInTraceback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '7', 'type': 'block', 'children': ['8', '12', '50']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'foundMethod'}; {'id': '11', 'type': 'False', 'children': []}; {'id': '12', 'type': 'for_statement', 'children': ['13', '14', '20']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_frames'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '20', 'type': 'block', 'children': ['21', '32']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'this'}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'f_locals'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'self'"}; {'id': '32', 'type': 'if_statement', 'children': ['33', '44']}; {'id': '33', 'type': 'boolean_operator', 'children': ['34', '37'], 'value': 'and'}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'is'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'this'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '43'], 'value': '=='}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'frame'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'f_code'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'co_name'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '44', 'type': 'block', 'children': ['45', '49']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'foundMethod'}; {'id': '48', 'type': 'True', 'children': []}; {'id': '49', 'type': 'break_statement', 'children': []}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'foundMethod'}
Returns boolean whether traceback contains method from this instance
def quotes_by_instrument_urls(cls, client, urls): instruments = ",".join(urls) params = {"instruments": instruments} url = "https://api.robinhood.com/marketdata/quotes/" data = client.get(url, params=params) results = data["results"] while "next" in data and data["next"]: data = client.get(data["next"]) results.extend(data["results"]) return results
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'quotes_by_instrument_urls'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '24', '28', '40', '46', '75']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'instruments'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'string', 'children': [], 'value': '","'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'urls'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '20', 'type': 'dictionary', 'children': ['21']}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"instruments"'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'instruments'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"https://api.robinhood.com/marketdata/quotes/"'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"results"'}; {'id': '46', 'type': 'while_statement', 'children': ['47', '54']}; {'id': '47', 'type': 'boolean_operator', 'children': ['48', '51'], 'value': 'and'}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'in'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"next"'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '53', 'type': 'string', 'children': [], 'value': '"next"'}; {'id': '54', 'type': 'block', 'children': ['55', '66']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'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': 'client'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '65', 'type': 'string', 'children': [], 'value': '"next"'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'subscript', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"results"'}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'results'}
fetch and return results
def delete_edge(self, source: str, target: str): if self.has_edge(source, target): self.remove_edge(source, target)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_edge'}; {'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': 'source'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'typed_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '22']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'has_edge'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'remove_edge'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'target'}
Removes an edge if it is in the graph.
def add_arguments(cls, parser, sys_arg_list=None): parser.add_argument('--icmp_check_interval', dest='icmp_check_interval', required=False, default=2, type=float, help="ICMPecho interval in seconds, default 2 " "(only for 'icmpecho' health monitor plugin)") return ["icmp_check_interval"]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_arguments'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'sys_arg_list'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '34']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '20', '23', '26', '29']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'--icmp_check_interval'"}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'icmp_check_interval'"}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'required'}; {'id': '22', 'type': 'False', 'children': []}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '31', 'type': 'concatenated_string', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"ICMPecho interval in seconds, default 2 "'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"(only for \'icmpecho\' health monitor plugin)"'}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'list', 'children': ['36'], 'value': '["icmp_check_interval"]'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"icmp_check_interval"'}
Arguments for the ICMPecho health monitor plugin.
def get(self, request, *args, **kwargs): serializer = self.serializer_reader_class if request.user.is_authenticated(): return Response(serializer(request.user, context=self.get_serializer_context()).data) else: return Response({'detail': _('Authentication credentials were not provided')}, status=401)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '17']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'serializer_reader_class'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '25', '45']}; {'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': 'request'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'is_authenticated'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '44']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'serializer'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get_serializer_context'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '58']}; {'id': '51', 'type': 'dictionary', 'children': ['52']}; {'id': '52', 'type': 'pair', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'detail'"}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': "'Authentication credentials were not provided'"}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '401'}
return profile of current user if authenticated otherwise 401
def valid_ipv4(ip): match = _valid_ipv4.match(ip) if match is None: return False octets = match.groups() if len(octets) != 4: return False first = int(octets[0]) if first < 1 or first > 254: return False for i in range(1, 4): octet = int(octets[i]) if octet < 0 or octet > 255: return False return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'valid_ipv4'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '22', '30', '40', '49', '60', '88']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_valid_ipv4'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ip'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'is'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '18', 'type': 'None', 'children': []}; {'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': 'octets'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'if_statement', 'children': ['31', '37']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '36'], 'value': '!='}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'octets'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'False', 'children': []}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'octets'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '49', 'type': 'if_statement', 'children': ['50', '57']}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '54'], 'value': 'or'}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': '<'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': '>'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '254'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'False', 'children': []}; {'id': '60', 'type': 'for_statement', 'children': ['61', '62', '67']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '67', 'type': 'block', 'children': ['68', '77']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'octet'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'octets'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '77', 'type': 'if_statement', 'children': ['78', '85']}; {'id': '78', 'type': 'boolean_operator', 'children': ['79', '82'], 'value': 'or'}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '81'], 'value': '<'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'octet'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '84'], 'value': '>'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'octet'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '255'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'False', 'children': []}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'True', 'children': []}
check if ip is a valid ipv4
def add_user(cls, username, email): sanitized = str(cls.__sanitize_username(username)) logger.debug("Adding user to SeAT with username %s" % sanitized) password = cls.__generate_random_pass() ret = cls.exec_request('user', 'post', username=sanitized, email=str(email), password=password) logger.debug(ret) if cls._response_ok(ret): logger.info("Added SeAT user with username %s" % sanitized) return sanitized, password logger.info("Failed to add SeAT user with username %s" % sanitized) return None, None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_user'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '29', '37', '59', '66', '87', '96']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sanitized'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__sanitize_username'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'username'}; {'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': 'binary_operator', 'children': ['27', '28'], 'value': '%'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"Adding user to SeAT with username %s"'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sanitized'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '__generate_random_pass'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'exec_request'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46', '47', '50', '56']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'user'"}; {'id': '46', 'type': 'string', 'children': [], 'value': "'post'"}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sanitized'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'email'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'password'}; {'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': 'logger'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '73']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_response_ok'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '73', 'type': 'block', 'children': ['74', '83']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '82'], 'value': '%'}; {'id': '81', 'type': 'string', 'children': [], 'value': '"Added SeAT user with username %s"'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'sanitized'}; {'id': '83', 'type': 'return_statement', 'children': ['84']}; {'id': '84', 'type': 'expression_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'sanitized'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '95'], 'value': '%'}; {'id': '94', 'type': 'string', 'children': [], 'value': '"Failed to add SeAT user with username %s"'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'sanitized'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'expression_list', 'children': ['98', '99']}; {'id': '98', 'type': 'None', 'children': []}; {'id': '99', 'type': 'None', 'children': []}
Add user to service
def setTimeout(self, time): self.conversation.SetDDETimeout(round(time)) return self.conversation.GetDDETimeout()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setTimeout'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'conversation'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'SetDDETimeout'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'conversation'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'GetDDETimeout'}; {'id': '26', 'type': 'argument_list', 'children': []}
Set global timeout value, in seconds, for all DDE calls
def add_gateway_router(self, router, body=None): return self.put((self.router_path % router), body={'router': {'external_gateway_info': body}})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_gateway_router'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'router'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'put'}; {'id': '15', 'type': 'argument_list', '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': 'router_path'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'router'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '24', 'type': 'dictionary', 'children': ['25']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'router'"}; {'id': '27', 'type': 'dictionary', 'children': ['28']}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'external_gateway_info'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'body'}
Adds an external network gateway to the specified router.
def _sanity_check_registered_locations_parent_locations(query_metadata_table): for location, location_info in query_metadata_table.registered_locations: if (location != query_metadata_table.root_location and not query_metadata_table.root_location.is_revisited_at(location)): if location_info.parent_location is None: raise AssertionError(u'Found a location that is not the root location of the query ' u'or a revisit of the root, but does not have a parent: ' u'{} {}'.format(location, location_info)) if location_info.parent_location is not None: query_metadata_table.get_location_info(location_info.parent_location)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sanity_check_registered_locations_parent_locations'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'query_metadata_table'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '13']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'location_info'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'query_metadata_table'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'registered_locations'}; {'id': '13', 'type': 'block', 'children': ['14', '53']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '31']}; {'id': '15', 'type': '()', 'children': ['16']}; {'id': '16', 'type': 'boolean_operator', 'children': ['17', '22'], 'value': 'and'}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': '!='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'query_metadata_table'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'root_location'}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'query_metadata_table'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'root_location'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'is_revisited_at'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '38']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '37'], 'value': 'is'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'location_info'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'parent_location'}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'raise_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'AssertionError'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '50']}; {'id': '44', 'type': 'attribute', 'children': ['45', '49']}; {'id': '45', 'type': 'concatenated_string', 'children': ['46', '47', '48']}; {'id': '46', 'type': 'string', 'children': [], 'value': "u'Found a location that is not the root location of the query '"}; {'id': '47', 'type': 'string', 'children': [], 'value': "u'or a revisit of the root, but does not have a parent: '"}; {'id': '48', 'type': 'string', 'children': [], 'value': "u'{} {}'"}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'location_info'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '59']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '58'], 'value': 'is not'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'location_info'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'parent_location'}; {'id': '58', 'type': 'None', 'children': []}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'query_metadata_table'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'get_location_info'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'location_info'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'parent_location'}
Assert that all registered locations' parent locations are also registered.
def bernard_auth(func): @wraps(func) async def wrapper(request: Request): def get_query_token(): token_key = settings.WEBVIEW_TOKEN_KEY return request.query.get(token_key, '') def get_header_token(): header_key = settings.WEBVIEW_HEADER_NAME return request.headers.get(header_key, '') try: token = next(filter(None, [ get_header_token(), get_query_token(), ])) except StopIteration: token = '' try: body = await request.json() except ValueError: body = None msg, platform = await manager.message_from_token(token, body) if not msg: return json_response({ 'status': 'unauthorized', 'message': 'No valid token found', }, status=401) return await func(msg, platform) return wrapper
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bernard_auth'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '142']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '12']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '12', 'type': 'function_definition', 'children': ['13', '14', '19']}; {'id': '13', 'type': 'function_name', 'children': [], 'value': 'wrapper'}; {'id': '14', 'type': 'parameters', 'children': ['15']}; {'id': '15', 'type': 'typed_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '17', 'type': 'type', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Request'}; {'id': '19', 'type': 'block', 'children': ['20', '40', '60', '86', '104', '117', '135']}; {'id': '20', 'type': 'function_definition', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'function_name', 'children': [], 'value': 'get_query_token'}; {'id': '22', 'type': 'parameters', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24', '30']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'token_key'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'WEBVIEW_TOKEN_KEY'}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'token_key'}; {'id': '39', 'type': 'string', 'children': [], 'value': "''"}; {'id': '40', 'type': 'function_definition', 'children': ['41', '42', '43']}; {'id': '41', 'type': 'function_name', 'children': [], 'value': 'get_header_token'}; {'id': '42', 'type': 'parameters', 'children': []}; {'id': '43', 'type': 'block', 'children': ['44', '50']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'header_key'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'WEBVIEW_HEADER_NAME'}; {'id': '50', 'type': 'return_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': 'request'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'header_key'}; {'id': '59', 'type': 'string', 'children': [], 'value': "''"}; {'id': '60', 'type': 'try_statement', 'children': ['61', '79']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'None', 'children': []}; {'id': '72', 'type': 'list', 'children': ['73', '76'], 'value': '[\n get_header_token(),\n get_query_token(),\n ]'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_header_token'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'get_query_token'}; {'id': '78', 'type': 'argument_list', 'children': []}; {'id': '79', 'type': 'except_clause', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'StopIteration'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '85', 'type': 'string', 'children': [], 'value': "''"}; {'id': '86', 'type': 'try_statement', 'children': ['87', '97']}; {'id': '87', 'type': 'block', 'children': ['88']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '91', 'type': 'await', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'id': '97', 'type': 'except_clause', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '103', 'type': 'None', 'children': []}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '109']}; {'id': '106', 'type': 'pattern_list', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '109', 'type': 'await', 'children': ['110']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'message_from_token'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '117', 'type': 'if_statement', 'children': ['118', '120']}; {'id': '118', 'type': 'not_operator', 'children': ['119']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'return_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'json_response'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '132']}; {'id': '125', 'type': 'dictionary', 'children': ['126', '129']}; {'id': '126', 'type': 'pair', 'children': ['127', '128']}; {'id': '127', 'type': 'string', 'children': [], 'value': "'status'"}; {'id': '128', 'type': 'string', 'children': [], 'value': "'unauthorized'"}; {'id': '129', 'type': 'pair', 'children': ['130', '131']}; {'id': '130', 'type': 'string', 'children': [], 'value': "'message'"}; {'id': '131', 'type': 'string', 'children': [], 'value': "'No valid token found'"}; {'id': '132', 'type': 'keyword_argument', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '134', 'type': 'integer', 'children': [], 'value': '401'}; {'id': '135', 'type': 'return_statement', 'children': ['136']}; {'id': '136', 'type': 'await', 'children': ['137']}; {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '139', 'type': 'argument_list', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'platform'}; {'id': '142', 'type': 'return_statement', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'wrapper'}
Authenticates the users based on the query-string-provided token
def zscan(self, key, cursor=0, match=None, count=None): args = [] if match is not None: args += [b'MATCH', match] if count is not None: args += [b'COUNT', count] fut = self.execute(b'ZSCAN', key, cursor, *args) def _converter(obj): return (int(obj[0]), pairs_int_or_float(obj[1])) return wait_convert(fut, _converter)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zscan'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16', '20', '31', '42', '55', '74']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '19', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '24']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': 'is not'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'augmented_assignment', 'children': ['27', '28'], 'value': '+='}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '28', 'type': 'list', 'children': ['29', '30'], 'value': "[b'MATCH', match]"}; {'id': '29', 'type': 'string', 'children': [], 'value': "b'MATCH'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '35']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'is not'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'augmented_assignment', 'children': ['38', '39'], 'value': '+='}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '39', 'type': 'list', 'children': ['40', '41'], 'value': "[b'COUNT', count]"}; {'id': '40', 'type': 'string', 'children': [], 'value': "b'COUNT'"}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fut'}; {'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': 'execute'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51', '52', '53']}; {'id': '50', 'type': 'string', 'children': [], 'value': "b'ZSCAN'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '53', 'type': 'list_splat', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '55', 'type': 'function_definition', 'children': ['56', '57', '59']}; {'id': '56', 'type': 'function_name', 'children': [], 'value': '_converter'}; {'id': '57', 'type': 'parameters', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'tuple', 'children': ['62', '68']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pairs_int_or_float'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'wait_convert'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'fut'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '_converter'}
Incrementally iterate sorted sets elements and associated scores.
def to_literal(self): if not self.nodes: return (self.tag, self.attrib, self.text, []) else: return (self.tag, self.attrib, self.text, list(map(to_literal, self.nodes)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_literal'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11', '24']}; {'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': 'nodes'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'tuple', 'children': ['14', '17', '20', '23']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '23', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'tuple', 'children': ['28', '31', '34', '37']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'attrib'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'to_literal'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'nodes'}
Convert the node into a literal Python object
def process_next_message(self, timeout): message = self.worker_manager.receive(timeout) if isinstance(message, Acknowledgement): self.task_manager.task_start(message.task, message.worker) elif isinstance(message, Result): self.task_manager.task_done(message.task, message.result)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_next_message'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '6', 'type': 'block', 'children': ['7', '18']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'message'}; {'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': 'worker_manager'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'receive'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '24', '39']}; {'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': 'message'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Acknowledgement'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'task_manager'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'task_start'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'worker'}; {'id': '39', 'type': 'elif_clause', 'children': ['40', '45']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'Result'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '53']}; {'id': '48', 'type': 'attribute', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'task_manager'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'task_done'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'result'}
Processes the next message coming from the workers.
def _get_struct_glowfilter(self): obj = _make_object("GlowFilter") obj.GlowColor = self._get_struct_rgba() obj.BlurX = unpack_fixed16(self._src) obj.BlurY = unpack_fixed16(self._src) obj.Strength = unpack_fixed8(self._src) bc = BitConsumer(self._src) obj.InnerGlow = bc.u_get(1) obj.Knockout = bc.u_get(1) obj.CompositeSource = bc.u_get(1) obj.Passes = bc.u_get(5) return obj
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_struct_glowfilter'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '23', '34', '45', '56', '65', '76', '87', '98', '109']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_make_object'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"GlowFilter"'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'GlowColor'}; {'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_struct_rgba'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'BlurX'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'unpack_fixed16'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_src'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'BlurY'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'unpack_fixed16'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_src'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Strength'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'unpack_fixed8'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_src'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'bc'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'BitConsumer'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_src'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'InnerGlow'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'bc'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'u_get'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'Knockout'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'bc'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'u_get'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'CompositeSource'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'bc'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'u_get'}; {'id': '96', 'type': 'argument_list', 'children': ['97']}; {'id': '97', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'Passes'}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'bc'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'u_get'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '109', 'type': 'return_statement', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'obj'}
Get the values for the GLOWFILTER record.