Commits

Martin Scharrer committed 6e15ae5

Implemented methods of Node class.

  • Participants
  • Parent commits ee48742

Comments (0)

Files changed (1)

File py/SvnDumpLoad/Format.py

         (1, 'Content-length'),
     )
 
+    def __init__(self, path, action, kind=None, copyfrom_path=None, copyfrom_rev=None, text_content=None):
+        super(Node, self).__init__()
+        self._headers['Node-path'] = path
+        self._headers['Node-action'] = action
+        if kind is not None:
+            self._headers['Node-kind'] = kind
+        if copyfrom_path is not None:
+            self._headers['Node-copyfrom-path'] = copyfrom_path
+        if copyfrom_rev is not None:
+            self._headers['Node-copyfrom-rev'] = copyfrom_rev
+        if text_content is not None:
+            self.set_text_content(text_content)
+
+    @classmethod
+    def create_empty(cls):
+        return cls(None, None)
+
+    def set_path(self, path):
+        self._headers['Node-path'] = path
+
+    def get_path(self):
+        return self._headers['Node-path']
+
+    def set_action(self, action):
+        self._headers['Node-action'] = action
+
+    def get_action(self):
+        return self._headers['Node-action']
+
+    def set_kind(self, kind):
+        self._headers['Node-kind'] = kind
+
+    def get_kind(self, default=None):
+        return self._headers.get('Node-kind', default)
+
+    def set_copyfrom_path(self, copyfrom_path):
+        self._headers['Node-copyfrom-path'] = copyfrom_path
+
+    def get_copyfrom_path(self, default=None):
+        return self._headers.get('Node-copyfrom-path', default)
+
+    def set_copyfrom_rev(self, copyfrom_rev):
+        self._headers['Node-copyfrom-rev'] = copyfrom_rev
+
+    def get_copyfrom_rev(self, default=None):
+        return self._headers.get('Node-copyfrom-rev', default)
+
+    def is_dir(self):
+        return self._headers.get('Node-kind') == "dir"
+
+    def is_file(self):
+        return self._headers.get('Node-kind') == "file"
+
+    def is_copy(self):
+        return 'Node-copyfrom-path' in self._headers
+
+
+
 
 class Version(Record):
     """ SVN dump-load record for the dumpfile version. """