Exemplo n.º 1
0
 def _calcpostlf(self, values):
     valuecount = len(values)
     sametype = False
     for i in range(valuecount):
         value = values[i]
         if i + 1 == valuecount:
             value.postlf = 0
             continue
         if i + 1 < valuecount:
             sametype = value.__class__ is values[i + 1].__class__
         if not sametype:
             if IDocstring.providedBy(values[i + 1]):
                 value.postlf = 0
                 continue
             if IDocstring.providedBy(value):
                 if IFunction.providedBy(value.__parent__):
                     value.postlf = 0
                 else:
                     value.postlf = 1
                 continue
             value.postlf = 1
             continue
         if IClass.providedBy(value) or IFunction.providedBy(value):
             value.postlf = 1
             continue
         value.postlf = 0
Exemplo n.º 2
0
 def _calcpostlf(self, values):
     valuecount = len(values)
     sametype = False
     for i in range(valuecount):
         value = values[i]
         if i + 1 == valuecount:
             value.postlf = 0
             continue
         if i + 1 < valuecount:
             sametype = value.__class__ is values[i + 1].__class__
         if not sametype:
             if IDocstring.providedBy(values[i + 1]):
                 value.postlf = 0
                 continue
             if IDocstring.providedBy(value):
                 if IFunction.providedBy(value.__parent__):
                     value.postlf = 0
                 else:
                     value.postlf = 1
                 continue
             value.postlf = 1
             continue
         if IClass.providedBy(value) \
           or IFunction.providedBy(value):
             value.postlf = 1
             continue
         value.postlf = 0
Exemplo n.º 3
0
 def __call__(self):
     if self.model.functionname is None:
         raise Incomplete, u"Incomplete function definition."
     
     showNotImplemented=True
     ret = list()
     for decorator in self.model.filtereditems(IDecorator):
         ret.append(decorator())
     name = self.model.functionname
     level = self.model.nodelevel
     args, kwargs = self.model.extract_arguments()
     indent = level * 4 * u' '
     base_str = u'def %s(' % name
     rfunc = u'%s%s' % (indent, base_str)
     parent=self.model.__parent__
     if not IClass.providedBy(parent) and u'self' in args:
         args = args[1:]
     if IClass.providedBy(parent):
         #add self to methods, but only if the class is not an interface
         try:
             isInterface=token(str(parent.uuid),False,isInterface=False).isInterface
         except ComponentLookupError:
             isInterface=False
         if not isInterface  and not u'self' in args:
             args = [u'self'] + args
         else:
             showNotImplemented=False #interface methods are empty on purpose
     rargs = self.render_arguments(level, len(name) + 5, args, kwargs)
     rfunc = u'%s%s):\n' % (rfunc, rargs)
     ret.append(rfunc)
     values = [val for val in self.model.values() \
               if not IDecorator.providedBy(val)]
     for child in values:
         child.postlf = 0
         ret.append(child())
     if not values:
         if showNotImplemented:
             ret.append(u'%s    raise NotImplementedError, "stub generated by AGX."\n' % indent)
         else:
             ret.append(u'%s    pass\n' % indent)
             
     ret += [u'\n' for i in range(self.model.postlf)]
     return u''.join(ret)