How to use dotted_name method in green

Best Python code snippet using green

grammator_imports.py

Source:grammator_imports.py Github

copy

Full Screen

...127 (dotted_name_element,) = pack128 return dotted_name_element129 @pg.production("dotted_name_element : NAME")130 @pg.production("dotted_name_element : SPACE")131 def dotted_name(pack):132 (token,) = pack133 return [create_node_from_token(token)]134 @pg.production("dotted_name_element : DOT")135 def dotted_name_dot(pack):136 (dot,) = pack137 return [{138 "type": "dot",139 "first_formatting": dot.hidden_tokens_before,140 "second_formatting": dot.hidden_tokens_after,...

Full Screen

Full Screen

interface.py

Source:interface.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2from Acquisition import aq_base3from Products.Five.browser import BrowserView4from interfaces import IInterfaceInformation5from plone.memoize.view import memoize6from zope.dottedname.resolve import resolve7from zope.interface import Interface, implements, providedBy8from zope.interface.interfaces import IMethod9def resolveInterface(dotted_name):10 klass = resolve(dotted_name)11 if not issubclass(klass, Interface):12 raise ValueError('%r is not a valid Interface.' % dotted_name)13 return klass14def getDottedName(iface):15 return "%s.%s" % (iface.__module__, iface.__name__)16def _trim_doc_string(text):17 """18 Trims a doc string to make it format19 correctly with structured text.20 """21 text = text.strip().replace('\r\n', '\n')22 lines = text.split('\n')23 nlines = [lines[0]]24 if len(lines) > 1:25 min_indent = None26 for line in lines[1:]:27 indent = len(line) - len(line.lstrip())28 if indent < min_indent or min_indent is None:29 min_indent = indent30 for line in lines[1:]:31 nlines.append(line[min_indent:])32 return '\n'.join(nlines)33def visitBaseInterfaces(iface, lst):34 bases = iface.getBases()35 for base in bases:36 if base in lst:37 return38 lst.append(base)39 visitBaseInterfaces(iface, lst)40class InterfaceInformation(BrowserView):41 implements(IInterfaceInformation)42 @memoize43 def provides(self, dotted_name):44 iface = resolveInterface(dotted_name)45 return iface.providedBy(aq_base(self.context))46 @memoize47 def class_provides(self, dotted_name):48 iface = resolveInterface(dotted_name)49 return iface.providedBy(aq_base(self.context).__class__)50 @memoize51 def names_and_descriptions(self, dotted_name, all=0):52 """ Returns a list of pairs (name, description) for a given53 interface"""54 iface = resolveInterface(dotted_name)55 nd = iface.namesAndDescriptions(all=all)56 return [(n, d.getDoc()) for n, d in nd]57 @memoize58 def get_interfaces(self):59 """Returns the list of interfaces which are implemented by the object60 """61 return tuple(providedBy(aq_base(self.context)).flattened())62 def get_base_interface(self):63 """Returns all base interfaces of an object but no direct interfaces64 Base interfaces are the interfaces which are the super interfaces of65 the direct interfaces66 """67 ifaces = self.get_interfaces()68 bases = []69 for iface in ifaces:70 visitBaseInterfaces(iface, bases)71 return [biface for biface in bases if biface not in ifaces]72 def get_interface_informations(self, iface):73 """Gets all useful informations from an iface74 * name75 * dotted name76 * trimmed doc string77 * base interfaces78 * methods with signature and trimmed doc string79 * attributes with trimemd doc string80 """81 bases = [base for base in iface.getBases()]82 attributes = []83 methods = []84 for name, desc in iface.namesAndDescriptions():85 if IMethod.providedBy(desc):86 methods.append({'signature': desc.getSignatureString(),87 'name': desc.getName(),88 'doc': _trim_doc_string(desc.getDoc())89 }90 )91 else:92 attributes.append({'name': desc.getName(),93 'doc': _trim_doc_string(desc.getDoc()),94 }95 )96 result = {97 'name': iface.getName(),98 'dotted_name': getDottedName(iface),99 'doc': _trim_doc_string(desc.getDoc()),100 'bases': bases,101 'base_names': [getDottedName(iface) for base in bases],102 'attributes': attributes,103 'methods': methods,104 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful