summaryrefslogtreecommitdiff
path: root/obalie/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'obalie/client.py')
-rw-r--r--obalie/client.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/obalie/client.py b/obalie/client.py
index d943bb8..cc40122 100644
--- a/obalie/client.py
+++ b/obalie/client.py
@@ -7,6 +7,7 @@ Subversion Client
7@date: April 20, 2010 7@date: April 20, 2010
8""" 8"""
9 9
10from xml.dom import pulldom
10from urlparse import urlparse 11from urlparse import urlparse
11from obalie.commands import load_commands 12from obalie.commands import load_commands
12from obalie.exceptions import UnsupportedCommand 13from obalie.exceptions import UnsupportedCommand
@@ -15,6 +16,10 @@ from obalie.utils import run_command
15 16
16 17
17class Client(object): 18class Client(object):
19 """
20 Subversion client that supports both remote and local subversion
21 repositories.
22 """
18 23
19 @inject_logger 24 @inject_logger
20 def __init__(self, repo_url, trust_server=True, config_dir=None, 25 def __init__(self, repo_url, trust_server=True, config_dir=None,
@@ -24,7 +29,7 @@ class Client(object):
24 self.config_dir = config_dir 29 self.config_dir = config_dir
25 self.trust_server = trust_server 30 self.trust_server = trust_server
26 self.additional_config = config 31 self.additional_config = config
27 self.verbosity = None 32 self._repository_info = None
28 self.commands = {} 33 self.commands = {}
29 34
30 self._unpack_url(repo_url) 35 self._unpack_url(repo_url)
@@ -37,11 +42,17 @@ class Client(object):
37 self.commands = load_commands() 42 self.commands = load_commands()
38 43
39 try: 44 try:
40 cmd = self.commands[name](self) 45 return self.commands[name](self)
41 return cmd
42 except KeyError: 46 except KeyError:
43 raise UnsupportedCommand(name) 47 raise UnsupportedCommand(name)
44 48
49 @property
50 def repository_info(self):
51 if not self._repository_info:
52 self._repository_info = self.info()
53
54 return self._repository_info
55
45 def _unpack_url(self, url): 56 def _unpack_url(self, url):
46 """ 57 """
47 Parses a repository URL and loads its parts into the instance. 58 Parses a repository URL and loads its parts into the instance.
@@ -83,10 +94,22 @@ class Client(object):
83 94
84 return ' '.join(args) 95 return ' '.join(args)
85 96
86 def run_raw_command(self, subcommand, *args): 97 def run_raw_command(self, subcommand, *args, **kwargs):
87 command = [self.command, self._get_svn_args(), subcommand] 98 """
99 Runs a raw subversion command and returns the results.
100 """
101 cmd_args = kwargs.pop('cmd_args', '')
102 command = [self.command, cmd_args, self._get_svn_args(), subcommand]
88 command = ' '.join(command + list(args)) 103 command = ' '.join(command + list(args))
89 104
90 self.logger.debug("Command: %r", command) 105 self.logger.debug("Command: %r", command)
91 106
92 return run_command(command) 107 return run_command(command, **kwargs)
108
109 def get_xml_output(self, subcommand, *args):
110 """
111 Runs a raw command passing the XML flag and returns a pulldom
112 instance ready for use.
113 """
114 output = self.run_raw_command(subcommand, *args, raw_output=True, cmd_args='--xml')
115 return pulldom.parseString(output)