Advertisement
Guest User

Untitled

a guest
May 17th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.79 KB | None | 0 0
  1. diff --git a/nodes.py b/nodes.py
  2. index 34864bd..150dc1c 100644
  3. --- a/nodes.py
  4. +++ b/nodes.py
  5. @@ -39,7 +39,16 @@ class Node(object):
  6.      def __init__(self):pass
  7.  
  8.      def __repr__(self):
  9. -        return self.__class__.__name__
  10. +    #    return self.__class__.__name__
  11. +
  12. +    #def __str__(self):
  13. +        cls = self.__class__
  14. +        string = cls.__name__
  15. +        print("TYPE", list(map(type, self.init_args)))
  16. +        print("IA",self.init_args)
  17. +        if self.init_args:
  18. +            return str(self.init_args)
  19. +        return string
  20.  
  21.      def __call__(self, args):
  22.          self.added_args = 0
  23. @@ -127,6 +136,8 @@ class Node(object):
  24.          pass
  25.  
  26.      def add_arg(self, args):
  27. +        print("self", self)
  28. +        print("repr %r"%(self))
  29.          if settings.WARNINGS: print("Missing arg to %r, evaling input."%self)
  30.          arg = safe_eval.evals[settings.SAFE](input())
  31.          if self.__class__.reverse_first:
  32. @@ -169,7 +180,9 @@ class Node(object):
  33.                          results = results([])[0]
  34.                      args.append(results)
  35.                  #print(code, cls, args)
  36. -            return code, cls(*args)
  37. +            obj = cls(*args)
  38. +            obj.setup_repr(args)
  39. +            return code, obj
  40.          return None, None
  41.  
  42.      @classmethod
  43. @@ -206,7 +219,10 @@ class Node(object):
  44.                              raise(AssertionError(cls.__name__+"(%r): returned %r. Has True/False"%(in_stack, rtn_stack)))
  45.                      if rtn_stack != out_stack:
  46.                          raise AssertionError(cls.__name__+"(%r): %r returned %r"%(in_stack, out_stack, rtn_stack))
  47. -
  48. +
  49. +    def setup_repr(self, args):
  50. +        self.init_args = args
  51. +
  52.      def prefer(func):
  53.          func.prefer = True
  54.          return func
  55. diff --git a/settings.py b/settings.py
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement