summaryrefslogtreecommitdiff
path: root/obalie/commands/info.py
diff options
context:
space:
mode:
Diffstat (limited to 'obalie/commands/info.py')
-rw-r--r--obalie/commands/info.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/obalie/commands/info.py b/obalie/commands/info.py
new file mode 100644
index 0000000..5bd29fd
--- /dev/null
+++ b/obalie/commands/info.py
@@ -0,0 +1,54 @@
1# vim: set filencoding=utf8
2"""
3Subversion Info
4
5@author: Mike Crute (mcrute@ag.com)
6@organization: SoftGroup Interactive, Inc.
7@date: April 20, 2010
8"""
9
10
11import os
12from xml.dom import pulldom
13from obalie.utils import join_url
14from obalie.commands import BaseCommand
15
16
17class RepositoryInfo(object):
18
19 def __init__(self, path=None, root=None, uuid=None, revision=None):
20 self.path = path
21 self.root = root
22 self.uuid = uuid
23 self.revision = revision
24
25 @property
26 def relative_path(self):
27 return self.path[len(self.root):]
28
29
30class InfoCommand(BaseCommand):
31
32 def __call__(self, path='/'):
33 path = join_url(self.client.repo_url, path)
34 self.logger.info('Running info for path: %s', path)
35
36 repo_info = RepositoryInfo()
37
38 xml = self.client.get_xml_output('info', path)
39 for event, node in xml:
40 if event != pulldom.START_ELEMENT:
41 continue
42
43 if node.tagName in ('url', 'root', 'uuid'):
44 xml.expandNode(node)
45
46 if node.tagName == 'url':
47 repo_info.path = node.firstChild.data
48 elif node.tagName == 'root':
49 repo_info.root = node.firstChild.data
50 elif node.tagName == 'uuid':
51 repo_info.uuid = node.firstChild.data
52
53 return repo_info
54