MCPcopy Create free account
hub / github.com/ActiveState/code / Node

Class Node

recipes/Python/473884_VSS_Integration_Module/recipe-473884.py:85–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 return Node(item);
84
85class Node(Disposable, Searchable):
86 def __init__(self, comobject):
87 self.vssItem = comobject;
88
89 def __call__(self):
90 return self.__repr__();
91
92 #are these really needed on subclasses?
93 def __del__(self):
94 self.dispose();
95
96 def __iter__(self):
97 return self.iterkeys();
98
99 def __nonzero__(self):
100 return self.vssItem is not None;
101
102 def __repr__(self):
103 return "<Node.%s>" % str(self.name);
104
105 def iterkeys(self):
106 """Gets the immediate descendants of the current node."""
107 if self.vssItem is not None:
108 if not hasattr(self.vssItem, "Items"): return;
109 for item in self.vssItem.Items:
110 yield Node(item);
111
112 def descendants(self):
113 """Iterates over all the descendants of the current node,
114 in order, to the leaf level."""
115 if self.vssItem is not None:
116 for item in self.__gen(self.vssItem):
117 yield Node(item);
118
119 def __gen(self, root):
120 yield root;
121 if hasattr(root, "Items"):
122 for node in root.Items:
123 for item in self.__gen(node):
124 yield item;
125
126 #todo: sort out this hideous duplication!
127 def checkout(self, local=None, flags=None):
128 if self.vssItem is not None:
129 if local is not None:
130 if flags is not None:
131 self.vssItem.Checkout(Local=local, iFlags=flags);
132 else:
133 self.vssItem.Checkout(Local=local);
134 else:
135 if flags is not None:
136 self.vssItem.Checkout(iFlags=flags);
137 else:
138 self.vssItem.Checkout();
139
140 #todo: sort out this hideous duplication!
141 def checkin(self, local=None, flags=None):
142 if self.vssItem is not None:

Callers 6

__getitem__Method · 0.70
iterkeysMethod · 0.70
descendantsMethod · 0.70
__parentMethod · 0.70
iterkeysMethod · 0.70
openProjectMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected