nodes.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
  2. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
  3. # copyright 2003-2010 Sylvain Thenault, all rights reserved.
  4. # contact mailto:thenault@gmail.com
  5. #
  6. # This file is part of logilab-astng.
  7. #
  8. # logilab-astng is free software: you can redistribute it and/or modify it
  9. # under the terms of the GNU Lesser General Public License as published by the
  10. # Free Software Foundation, either version 2.1 of the License, or (at your
  11. # option) any later version.
  12. #
  13. # logilab-astng is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  16. # for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General Public License along
  19. # with logilab-astng. If not, see <http://www.gnu.org/licenses/>.
  20. """
  21. on all nodes :
  22. .is_statement, returning true if the node should be considered as a
  23. statement node
  24. .root(), returning the root node of the tree (i.e. a Module)
  25. .previous_sibling(), returning previous sibling statement node
  26. .next_sibling(), returning next sibling statement node
  27. .statement(), returning the first parent node marked as statement node
  28. .frame(), returning the first node defining a new local scope (i.e.
  29. Module, Function or Class)
  30. .set_local(name, node), define an identifier <name> on the first parent frame,
  31. with the node defining it. This is used by the astng builder and should not
  32. be used from out there.
  33. on From and Import :
  34. .real_name(name),
  35. """
  36. __docformat__ = "restructuredtext en"
  37. from logilab.astng.node_classes import Arguments, AssAttr, Assert, Assign, \
  38. AssName, AugAssign, Backquote, BinOp, BoolOp, Break, CallFunc, Compare, \
  39. Comprehension, Const, Continue, Decorators, DelAttr, DelName, Delete, \
  40. Dict, Discard, Ellipsis, EmptyNode, ExceptHandler, Exec, ExtSlice, For, \
  41. From, Getattr, Global, If, IfExp, Import, Index, Keyword, \
  42. List, Name, Nonlocal, Pass, Print, Raise, Return, Set, Slice, Starred, Subscript, \
  43. TryExcept, TryFinally, Tuple, UnaryOp, While, With, Yield, \
  44. const_factory
  45. from logilab.astng.scoped_nodes import Module, GenExpr, Lambda, DictComp, \
  46. ListComp, SetComp, Function, Class
  47. ALL_NODE_CLASSES = (
  48. Arguments, AssAttr, Assert, Assign, AssName, AugAssign,
  49. Backquote, BinOp, BoolOp, Break,
  50. CallFunc, Class, Compare, Comprehension, Const, Continue,
  51. Decorators, DelAttr, DelName, Delete,
  52. Dict, DictComp, Discard,
  53. Ellipsis, EmptyNode, ExceptHandler, Exec, ExtSlice,
  54. For, From, Function,
  55. Getattr, GenExpr, Global,
  56. If, IfExp, Import, Index,
  57. Keyword,
  58. Lambda, List, ListComp,
  59. Name, Nonlocal,
  60. Module,
  61. Pass, Print,
  62. Raise, Return,
  63. Set, SetComp, Slice, Starred, Subscript,
  64. TryExcept, TryFinally, Tuple,
  65. UnaryOp,
  66. While, With,
  67. Yield,
  68. )