code stringlengths 1 18.2k |
|---|
def get_model_class( klass, api = None, use_request_api = True): """ Generates the Model Class based on the klass loads automatically the corresponding json schema file form schemes folder :param klass: json schema filename :param use_request_api: if True autoinitializes request class if api is None :param api: the tra... |
def validate(self, data): """Apply a JSON schema to an object""" try: schema_path = os.path.normpath(SCHEMA_ROOT) location = u'file://%s' % (schema_path) fs_resolver = resolver.LocalRefResolver(location, self.schema) jsonschema.Draft3Validator(self.schema, resolver=fs_resolver).validate(data) except jsonschema.Validati... |
def save(self, *args, **kwargs): """ saves creates or updates current resource returns new resource """ self._pre_save(*args, **kwargs) response = self._save(*args, **kwargs) response = self._post_save(response, *args, **kwargs) return response |
def load(self, id, *args, **kwargs): """ loads a remote resource by id """ self._pre_load(id, *args, **kwargs) response = self._load(id, *args, **kwargs) response = self._post_load(response, *args, **kwargs) return response |
def delete(self, *args, **kwargs): """ deletes current resource returns response from api """ self._pre_delete(*args, **kwargs) response = self._delete(*args, **kwargs) response = self._post_delete(response, *args, **kwargs) return response |
def to_json(self): """ put the object to json and remove the internal stuff salesking schema stores the type in the title """ data = json.dumps(self) out = u'{"%s":%s}' % (self.schema['title'], data) return out |
def _do_api_call(self, call_type=u'', id = None): """ returns a response if it is a valid call otherwise the corresponding error """ endpoint = None url = None # print "call_type %s" % (call_type) if call_type == u'load': endpoint = self.get_endpoint("self") if id is None: raise APIException("LOAD_IDNOTSET", "could not... |
if id is not None: url = u"%s%s%s" % (self.__api__.base_url, API_BASE_PATH, endpoint['href'].replace(u"{id}",id)) ## excecute the api request payload = self.to_json() if u'method' in endpoint.keys(): method = endpoint['method'] else: method = u'GET' # request raises exceptions if something goes wrong obj = None try: # ... |
msg = "Exception occoured %s url: %s" % (e, url) log.error(msg) raise e |
def to_instance(self, response): """ transforms the content to a new instace of object self.schema['title'] :param content: valid response :returns new instance of current class """ klass = self.schema['title'] cls = get_model_class(klass, api=self.__api__) jdict = json.loads(response.content, encoding="utf-8") ### che... |
def dict_to_instance(self, content): """ transforms the content to a new instace of object self.schema['title'] :param content: valid response :returns new instance of current class """ klass = self.schema['title'] cls = get_model_class(klass, api=self.__api__) # jdict = json.loads(content, encoding="utf-8") ### check ... |
def get_locals(f): ''' returns a formatted view of the local variables in a frame ''' return pformat({i:f.f_locals[i] for i in f.f_locals if not i.startswith('__')}) |
def default_profiler(f, _type, _value): ''' inspects an input frame and pretty prints the following: <src-path>:<src-line> -> <function-name> <source-code> <local-variables> ---------------------------------------- ''' try: profile_print( '\n'.join([ get_frame_src(f), get_locals(f), '-----------------------------------... |
def open_logfile(filename, mode='a'): """Open the named log file in append mode. If the file already exists, a separator will also be printed to the file to separate past activity from current activity. """ filename = os.path.expanduser(filename) filename = os.path.abspath(filename) dirname = os.path.dirname(filename) ... |
def authenticate(realm, authid, details): """ application_name : name of your application version : version of your application required_components dictionary of components required for you application and their version required { "component" : "1.1", "component2" : "0.1", ... } when all the different component require... |
required_components): ready_defered = defer.Deferred() ready_defered.addCallback(defer_try_start_app, application_name=application_name, version=version, required_components=required_components) _waiting[application_name]['defer'] = ready_defered yield ready_defered print("[MESTR] start app: ", _start) print("[MESTR] w... |
def info(self, resource): ''' prints information/documentation on a provided resource ''' service_def, resource_def, path = self._get_service_information( resource) print (resource) print ("*******************************************") print ("Base URL: {0}" . format (self.tld)) print ("Resource path: {0}" . format (re... |
def create(self, resource, data): ''' A base function that performs a default create POST request for a given object ''' service_def, resource_def, path = self._get_service_information( resource) self._validate(resource, data) return self.call(path=path, data=data, method='post') |
def update(self, resource, resource_id, data): ''' A base function that performs a default create PATCH request for a given object ''' service_def, resource_def, path = self._get_service_information( resource) update_path = "{0}{1}/" . format(path, resource_id) return self.call(path=update_path, data=data, method='patc... |
def delete(self, resource, resource_id): ''' A base function that performs a default delete DELETE request for a given object ''' service_def, resource_def, path = self._get_service_information( resource) delete_path = "{0}{1}/" . format(path, resource_id) return self.call(path=delete_path, method="delete") |
def _make_api(self, service_name): ''' not yet in use .. ''' resources = [resource for resource, resource_details in service_definitions.get(service_name, {}).get("resources", {}).items()] for resource in resources: setattr(self, 'list_{0}' . format(resource), self.list) setattr(self, 'get_{0}' . format(resource), self... |
def getSystemIps(): """ will not return the localhost one """ IPs = [] for interface in NetInfo.getSystemIfs(): if not interface.startswith('lo'): ip = netinfo.get_ip(interface) IPs.append(ip) return IPs |
def getIPString(): """ return comma delimited string of all the system IPs""" if not(NetInfo.systemip): NetInfo.systemip = ",".join(NetInfo.getSystemIps()) return NetInfo.systemip |
def check_update(): """ Return True if an update is available on pypi """ r = requests.get("https://pypi.python.org/pypi/prof/json") data = r.json() if versiontuple(data['info']['version']) > versiontuple(__version__): return True return False |
def to_ut1unix(time: Union[str, datetime, float, np.ndarray]) -> np.ndarray: """ converts time inputs to UT1 seconds since Unix epoch """ # keep this order time = totime(time) if isinstance(time, (float, int)): return time if isinstance(time, (tuple, list, np.ndarray)): assert isinstance(time[0], datetime), f'expected ... |
def chapman_profile(Z0: float, zKM: np.ndarray, H: float): """ Z0: altitude [km] of intensity peak zKM: altitude grid [km] H: scale height [km] example: pz = chapman_profile(110,np.arange(90,200,1),20) """ return np.exp(.5*(1-(zKM-Z0)/H - np.exp((Z0-zKM)/H))) |
def parse_editable(editable_req, default_vcs=None): """Parses svn+http://blahblah@rev#egg=Foobar into a requirement (Foobar) and a URL""" url = editable_req if os.path.isdir(url) and os.path.exists(os.path.join(url, 'setup.py')): # Treating it as code that has already been checked out url = path_to_url(url) if url.lowe... |
if p] if parts[-2] in ('tags', 'branches', 'tag', 'branch'): req = parts[-3] elif parts[-1] == 'trunk': req = parts[-2] else: raise InstallationError( '--editable=%s is not the right format; it must have #egg=Package' % editable_req) else: req = match.group(1) ## FIXME: use package_to_requirement? match = re.search(r'^... |
def from_line(cls, name, comes_from=None): """Creates an InstallRequirement from a name, which might be a requirement, directory containing 'setup.py', filename, or URL. """ url = None name = name.strip() req = None path = os.path.normpath(os.path.abspath(name)) link = None if is_url(name): link = Link(name) elif os.pa... |
# Handle relative file URLs if link.scheme == 'file' and re.search(r'\.\./', url): url = path_to_url(os.path.normpath(os.path.abspath(link.path))) else: req = name return cls(req, comes_from, url=url) |
def remove_temporary_source(self): """Remove the source files from this requirement, if they are marked for deletion""" if self.is_bundle or os.path.exists(self.delete_marker_filename): logger.info('Removing source in %s' % self.source_dir) if self.source_dir: rmtree(self.source_dir) self.source_dir = None if self._tem... |
def check_if_exists(self): """Find an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.conflicts_with appropriately.""" if self.req is None: return False try: self.satisfied_by = pkg_resources.get_distribution(self.req) except pkg_resources.DistributionNotFound... |
def release(): """ Release current version to pypi """ with settings(warn_only=True): r = local(clom.git['diff-files']('--quiet', '--ignore-submodules', '--')) if r.return_code != 0: abort('There are uncommitted changes, commit or stash them before releasing') version = open('VERSION.txt').read().strip() print('Releasi... |
def execute(tokens): """ Perform the actions described by the input tokens. """ if not validate_rc(): print('Your .vacationrc file has errors!') echo_vacation_rc() return for action, value in tokens: if action == 'show': show() elif action == 'log': log_vacation_days() elif action == 'echo': echo_vacation_rc() elif act... |
def unique(transactions): """ Remove any duplicate entries. """ seen = set() # TODO: Handle comments return [x for x in transactions if not (x in seen or seen.add(x))] |
def sort(transactions): """ Return a list of sorted transactions by date. """ return transactions.sort(key=lambda x: datetime.datetime.strptime(x.split(':')[0], '%Y-%m-%d'))[:] |
def validate_rc(): """ Before we execute any actions, let's validate our .vacationrc. """ transactions = rc.read() if not transactions: print('Your .vacationrc file is empty! Set days and rate.') return False transactions = sort(unique(transactions)) return validate_setup(transactions) |
def validate_setup(transactions): """ First two transactions must set rate & days. """ if not transactions: return True try: first, second = transactions[:2] except ValueError: print('Error: vacationrc file must have both initial days and rates entries') return False parts1, parts2 = first.split(), second.split() if pa... |
def _parse_transaction_entry(entry): """ Validate & parse a transaction into (date, action, value) tuple. """ parts = entry.split() date_string = parts[0] try: date = datetime.datetime.strptime(date_string[:-1], '%Y-%m-%d').date() except ValueError: raise ValueError('Invalid date in vacationrc for entry: {}'.format(ent... |
def stat_holidays(province='BC', year=2015): """ Returns a list of holiday dates for a province and year. """ return holidays.Canada(state=province, years=year).keys() |
def sum_transactions(transactions): """ Sums transactions into a total of remaining vacation days. """ workdays_per_year = 250 previous_date = None rate = 0 day_sum = 0 for transaction in transactions: date, action, value = _parse_transaction_entry(transaction) if previous_date is None: previous_date = date elapsed = w... |
def get_days_off(transactions): """ Return the dates for any 'take day off' transactions. """ days_off = [] for trans in transactions: date, action, _ = _parse_transaction_entry(trans) if action == 'off': days_off.append(date) return days_off |
def log_vacation_days(): """ Sum and report taken days off. """ days_off = get_days_off(rc.read()) pretty_days = map(lambda day: day.strftime('%a %b %d %Y'), days_off) for day in pretty_days: print(day) |
def echo_vacation_rc(): """ Display all our .vacationrc file. """ contents = rc.read() print('.vacationrc\n===========') for line in contents: print(line.rstrip()) |
def to_email(email_class, email, language=None, **data): """ Send email to specified email address """ if language: email_class().send([email], language=language, **data) else: email_class().send([email], translation.get_language(), **data) |
def to_user(email_class, user, **data): """ Email user """ try: email_class().send([user.email], user.language, **data) except AttributeError: # this is a fallback in case the user model does not have the language field email_class().send([user.email], translation.get_language(), **data) |
def to_staff(email_class, **data): """ Email staff users """ for user in get_user_model().objects.filter(is_staff=True): try: email_class().send([user.email], user.language, **data) except AttributeError: email_class().send([user.email], translation.get_language(), **data) |
def to_superuser(email_class, **data): """ Email superusers """ for user in get_user_model().objects.filter(is_superuser=True): try: email_class().send([user.email], user.language, **data) except AttributeError: email_class().send([user.email], translation.get_language(), **data) |
def p_top_statement_namespace(p): '''top_statement : NAMESPACE namespace_name SEMI | NAMESPACE LBRACE top_statement_list RBRACE | NAMESPACE namespace_name LBRACE top_statement_list RBRACE''' if len(p) == 4: p[0] = ast.Namespace(p[2], [], lineno=p.lineno(1)) elif len(p) == 5: p[0] = ast.Namespace(None, p[3], lineno=p.li... |
def p_use_declaration(p): '''use_declaration : namespace_name | NS_SEPARATOR namespace_name | namespace_name AS STRING | NS_SEPARATOR namespace_name AS STRING''' if len(p) == 2: p[0] = ast.UseDeclaration(p[1], None, lineno=p.lineno(1)) elif len(p) == 3: p[0] = ast.UseDeclaration(p[1] + p[2], None, lineno=p.lineno(1)) e... |
def p_constant_declaration(p): 'constant_declaration : STRING EQUALS static_scalar' p[0] = ast.ConstantDeclaration(p[1], p[3], lineno=p.lineno(1)) |
def p_statement_if(p): '''statement : IF LPAREN expr RPAREN statement elseif_list else_single | IF LPAREN expr RPAREN COLON inner_statement_list new_elseif_list new_else_single ENDIF SEMI''' if len(p) == 8: p[0] = ast.If(p[3], p[5], p[6], p[7], lineno=p.lineno(1)) else: p[0] = ast.If(p[3], ast.Block(p[6], lineno=p.line... |
def p_statement_while(p): 'statement : WHILE LPAREN expr RPAREN while_statement' p[0] = ast.While(p[3], p[5], lineno=p.lineno(1)) |
def p_statement_do_while(p): 'statement : DO statement WHILE LPAREN expr RPAREN SEMI' p[0] = ast.DoWhile(p[2], p[5], lineno=p.lineno(1)) |
def p_statement_for(p): 'statement : FOR LPAREN for_expr SEMI for_expr SEMI for_expr RPAREN for_statement' p[0] = ast.For(p[3], p[5], p[7], p[9], lineno=p.lineno(1)) |
def p_statement_foreach(p): 'statement : FOREACH LPAREN expr AS foreach_variable foreach_optional_arg RPAREN foreach_statement' if p[6] is None: p[0] = ast.Foreach(p[3], None, p[5], p[8], lineno=p.lineno(1)) else: p[0] = ast.Foreach(p[3], p[5], p[6], p[8], lineno=p.lineno(1)) |
def p_statement_switch(p): 'statement : SWITCH LPAREN expr RPAREN switch_case_list' p[0] = ast.Switch(p[3], p[5], lineno=p.lineno(1)) |
def p_statement_break(p): '''statement : BREAK SEMI | BREAK expr SEMI''' if len(p) == 3: p[0] = ast.Break(None, lineno=p.lineno(1)) else: p[0] = ast.Break(p[2], lineno=p.lineno(1)) |
def p_statement_continue(p): '''statement : CONTINUE SEMI | CONTINUE expr SEMI''' if len(p) == 3: p[0] = ast.Continue(None, lineno=p.lineno(1)) else: p[0] = ast.Continue(p[2], lineno=p.lineno(1)) |
def p_statement_return(p): '''statement : RETURN SEMI | RETURN expr SEMI''' if len(p) == 3: p[0] = ast.Return(None, lineno=p.lineno(1)) else: p[0] = ast.Return(p[2], lineno=p.lineno(1)) |
def p_statement_try(p): 'statement : TRY LBRACE inner_statement_list RBRACE CATCH LPAREN fully_qualified_class_name VARIABLE RPAREN LBRACE inner_statement_list RBRACE additional_catches' p[0] = ast.Try(p[3], [ast.Catch(p[7], ast.Variable(p[8], lineno=p.lineno(8)), p[11], lineno=p.lineno(5))] + p[13], lineno=p.lineno(1)... |
def p_additional_catches(p): '''additional_catches : additional_catches CATCH LPAREN fully_qualified_class_name VARIABLE RPAREN LBRACE inner_statement_list RBRACE | empty''' if len(p) == 10: p[0] = p[1] + [ast.Catch(p[4], ast.Variable(p[5], lineno=p.lineno(5)), p[8], lineno=p.lineno(2))] else: p[0] = [] |
def p_statement_declare(p): 'statement : DECLARE LPAREN declare_list RPAREN declare_statement' p[0] = ast.Declare(p[3], p[5], lineno=p.lineno(1)) |
def p_declare_list(p): '''declare_list : STRING EQUALS static_scalar | declare_list COMMA STRING EQUALS static_scalar''' if len(p) == 4: p[0] = [ast.Directive(p[1], p[3], lineno=p.lineno(1))] else: p[0] = p[1] + [ast.Directive(p[3], p[5], lineno=p.lineno(2))] |
def p_declare_statement(p): '''declare_statement : statement | COLON inner_statement_list ENDDECLARE SEMI''' if len(p) == 2: p[0] = p[1] else: p[0] = ast.Block(p[2], lineno=p.lineno(1)) |
def p_elseif_list(p): '''elseif_list : empty | elseif_list ELSEIF LPAREN expr RPAREN statement''' if len(p) == 2: p[0] = [] else: p[0] = p[1] + [ast.ElseIf(p[4], p[6], lineno=p.lineno(2))] |
def p_else_single(p): '''else_single : empty | ELSE statement''' if len(p) == 3: p[0] = ast.Else(p[2], lineno=p.lineno(1)) |
def p_new_elseif_list(p): '''new_elseif_list : empty | new_elseif_list ELSEIF LPAREN expr RPAREN COLON inner_statement_list''' if len(p) == 2: p[0] = [] else: p[0] = p[1] + [ast.ElseIf(p[4], ast.Block(p[7], lineo=p.lineno(6)), lineno=p.lineno(2))] |
def p_new_else_single(p): '''new_else_single : empty | ELSE COLON inner_statement_list''' if len(p) == 4: p[0] = ast.Else(ast.Block(p[3], lineno=p.lineno(2)), lineno=p.lineno(1)) |
def p_while_statement(p): '''while_statement : statement | COLON inner_statement_list ENDWHILE SEMI''' if len(p) == 2: p[0] = p[1] else: p[0] = ast.Block(p[2], lineno=p.lineno(1)) |
def p_for_statement(p): '''for_statement : statement | COLON inner_statement_list ENDFOR SEMI''' if len(p) == 2: p[0] = p[1] else: p[0] = ast.Block(p[2], lineno=p.lineno(1)) |
def p_foreach_variable(p): '''foreach_variable : VARIABLE | AND VARIABLE''' if len(p) == 2: p[0] = ast.ForeachVariable(p[1], False, lineno=p.lineno(1)) else: p[0] = ast.ForeachVariable(p[2], True, lineno=p.lineno(1)) |
def p_foreach_statement(p): '''foreach_statement : statement | COLON inner_statement_list ENDFOREACH SEMI''' if len(p) == 2: p[0] = p[1] else: p[0] = ast.Block(p[2], lineno=p.lineno(1)) |
def p_case_list(p): '''case_list : empty | case_list CASE expr case_separator inner_statement_list | case_list DEFAULT case_separator inner_statement_list''' if len(p) == 6: p[0] = p[1] + [ast.Case(p[3], p[5], lineno=p.lineno(2))] elif len(p) == 5: p[0] = p[1] + [ast.Default(p[4], lineno=p.lineno(2))] else: p[0] = [] |
def p_global_var(p): '''global_var : VARIABLE | DOLLAR variable | DOLLAR LBRACE expr RBRACE''' if len(p) == 2: p[0] = ast.Variable(p[1], lineno=p.lineno(1)) elif len(p) == 3: p[0] = ast.Variable(p[2], lineno=p.lineno(1)) else: p[0] = ast.Variable(p[3], lineno=p.lineno(1)) |
def p_static_var(p): '''static_var : VARIABLE EQUALS static_scalar | VARIABLE''' if len(p) == 4: p[0] = ast.StaticVariable(p[1], p[3], lineno=p.lineno(1)) else: p[0] = ast.StaticVariable(p[1], None, lineno=p.lineno(1)) |
def p_function_declaration_statement(p): 'function_declaration_statement : FUNCTION is_reference STRING LPAREN parameter_list RPAREN LBRACE inner_statement_list RBRACE' p[0] = ast.Function(p[3], p[5], p[8], p[2], lineno=p.lineno(1)) |
def p_class_declaration_statement(p): '''class_declaration_statement : class_entry_type STRING extends_from implements_list LBRACE class_statement_list RBRACE | INTERFACE STRING interface_extends_list LBRACE class_statement_list RBRACE''' if len(p) == 8: p[0] = ast.Class(p[2], p[1], p[3], p[4], p[6], lineno=p.lineno(2)... |
def p_fully_qualified_class_name(p): '''fully_qualified_class_name : namespace_name | NS_SEPARATOR namespace_name | NAMESPACE NS_SEPARATOR namespace_name''' if len(p) == 2: p[0] = p[1] elif len(p) == 3: p[0] = p[1] + p[2] else: p[0] = p[1] + p[2] + p[3] |
def p_class_statement(p): '''class_statement : method_modifiers FUNCTION is_reference STRING LPAREN parameter_list RPAREN method_body | comment | variable_modifiers class_variable_declaration SEMI | class_constant_declaration SEMI''' if len(p) == 9: p[0] = ast.Method(p[4], p[1], p[6], p[8], p[3], lineno=p.lineno(2)) el... |
def p_class_variable_declaration_initial(p): '''class_variable_declaration : class_variable_declaration COMMA VARIABLE EQUALS static_scalar | VARIABLE EQUALS static_scalar''' if len(p) == 6: p[0] = p[1] + [ast.ClassVariable(p[3], p[5], lineno=p.lineno(2))] else: p[0] = [ast.ClassVariable(p[1], p[3], lineno=p.lineno(1))... |
def p_class_variable_declaration_no_initial(p): '''class_variable_declaration : class_variable_declaration COMMA VARIABLE | VARIABLE''' if len(p) == 4: p[0] = p[1] + [ast.ClassVariable(p[3], None, lineno=p.lineno(2))] else: p[0] = [ast.ClassVariable(p[1], None, lineno=p.lineno(1))] |
def p_class_constant_declaration(p): '''class_constant_declaration : class_constant_declaration COMMA STRING EQUALS static_scalar | CONST STRING EQUALS static_scalar''' if len(p) == 6: p[0] = p[1] + [ast.ClassConstant(p[3], p[5], lineno=p.lineno(2))] else: p[0] = [ast.ClassConstant(p[2], p[4], lineno=p.lineno(1))] |
def p_parameter(p): '''parameter : VARIABLE | class_name VARIABLE | ARRAY VARIABLE | AND VARIABLE | class_name AND VARIABLE | ARRAY AND VARIABLE | VARIABLE EQUALS static_scalar | class_name VARIABLE EQUALS static_scalar | ARRAY VARIABLE EQUALS static_scalar | AND VARIABLE EQUALS static_scalar | class_name AND VARIABLE ... |
'&': # STRING AND VARIABLE p[0] = ast.FormalParameter(p[3], None, True, p[1], lineno=p.lineno(1)) elif len(p) == 5 and p[1] == '&': # AND VARIABLE EQUALS static_scalar p[0] = ast.FormalParameter(p[2], p[4], True, None, lineno=p.lineno(1)) elif len(p) == 5 and p[1] != '&': # STRING VARIABLE EQUALS static_scalar p[0] = a... |
def p_expr_assign(p): '''expr : variable EQUALS expr | variable EQUALS AND expr''' if len(p) == 5: p[0] = ast.Assignment(p[1], p[4], True, lineno=p.lineno(2)) else: p[0] = ast.Assignment(p[1], p[3], False, lineno=p.lineno(2)) |
def p_expr_new(p): 'expr : NEW class_name_reference ctor_arguments' p[0] = ast.New(p[2], p[3], lineno=p.lineno(1)) |
def p_class_name(p): '''class_name : namespace_name | NS_SEPARATOR namespace_name | NAMESPACE NS_SEPARATOR namespace_name''' if len(p) == 2: p[0] = p[1] elif len(p) == 3: p[0] = p[1] + p[2] else: p[0] = p[1] + p[2] + p[3] |
def p_dynamic_class_name_reference(p): '''dynamic_class_name_reference : base_variable OBJECT_OPERATOR object_property dynamic_class_name_variable_properties | base_variable''' if len(p) == 5: name, dims = p[3] p[0] = ast.ObjectProperty(p[1], name, lineno=p.lineno(2)) for class_, dim, lineno in dims: p[0] = class_(p[0]... |
def p_expr_list_assign(p): 'expr : LIST LPAREN assignment_list RPAREN EQUALS expr' p[0] = ast.ListAssignment(p[3], p[6], lineno=p.lineno(1)) |
def p_variable(p): '''variable : base_variable_with_function_calls OBJECT_OPERATOR object_property method_or_not variable_properties | base_variable_with_function_calls''' if len(p) == 6: name, dims = p[3] params = p[4] if params is not None: p[0] = ast.MethodCall(p[1], name, params, lineno=p.lineno(2)) else: p[0] = as... |
def p_function_call(p): '''function_call : namespace_name LPAREN function_call_parameter_list RPAREN | NS_SEPARATOR namespace_name LPAREN function_call_parameter_list RPAREN | NAMESPACE NS_SEPARATOR namespace_name LPAREN function_call_parameter_list RPAREN''' if len(p) == 5: p[0] = ast.FunctionCall(p[1], p[3], lineno=p... |
def p_function_call_static(p): '''function_call : class_name DOUBLE_COLON STRING LPAREN function_call_parameter_list RPAREN | class_name DOUBLE_COLON variable_without_objects LPAREN function_call_parameter_list RPAREN | variable_class_name DOUBLE_COLON STRING LPAREN function_call_parameter_list RPAREN | variable_class_... |
def p_function_call_variable(p): 'function_call : variable_without_objects LPAREN function_call_parameter_list RPAREN' p[0] = ast.FunctionCall(p[1], p[3], lineno=p.lineno(2)) |
def p_simple_indirect_reference(p): '''simple_indirect_reference : DOLLAR simple_indirect_reference | reference_variable''' if len(p) == 3: p[0] = ast.Variable(p[2], lineno=p.lineno(1)) else: p[0] = p[1] |
def p_static_member(p): '''static_member : class_name DOUBLE_COLON variable_without_objects | variable_class_name DOUBLE_COLON variable_without_objects''' p[0] = ast.StaticProperty(p[1], p[3], lineno=p.lineno(2)) |
def p_reference_variable_array_offset(p): 'reference_variable : reference_variable LBRACKET dim_offset RBRACKET' p[0] = ast.ArrayOffset(p[1], p[3], lineno=p.lineno(2)) |
def p_reference_variable_string_offset(p): 'reference_variable : reference_variable LBRACE expr RBRACE' p[0] = ast.StringOffset(p[1], p[3], lineno=p.lineno(2)) |
def p_compound_variable(p): '''compound_variable : VARIABLE | DOLLAR LBRACE expr RBRACE''' if len(p) == 2: p[0] = ast.Variable(p[1], lineno=p.lineno(1)) else: p[0] = ast.Variable(p[3], lineno=p.lineno(1)) |
def p_non_empty_array_pair_list_item(p): '''non_empty_array_pair_list : non_empty_array_pair_list COMMA AND variable | non_empty_array_pair_list COMMA expr | AND variable | expr''' if len(p) == 5: p[0] = p[1] + [ast.ArrayElement(None, p[4], True, lineno=p.lineno(2))] elif len(p) == 4: p[0] = p[1] + [ast.ArrayElement(No... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.