From e74452aabeb77ab8ab8f50a350d77e4d9e6914a2 Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Wed, 21 Apr 2010 00:16:16 -0400 Subject: Adding basic info command --- obalie/client.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'obalie/client.py') 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 @date: April 20, 2010 """ +from xml.dom import pulldom from urlparse import urlparse from obalie.commands import load_commands from obalie.exceptions import UnsupportedCommand @@ -15,6 +16,10 @@ from obalie.utils import run_command class Client(object): + """ + Subversion client that supports both remote and local subversion + repositories. + """ @inject_logger def __init__(self, repo_url, trust_server=True, config_dir=None, @@ -24,7 +29,7 @@ class Client(object): self.config_dir = config_dir self.trust_server = trust_server self.additional_config = config - self.verbosity = None + self._repository_info = None self.commands = {} self._unpack_url(repo_url) @@ -37,11 +42,17 @@ class Client(object): self.commands = load_commands() try: - cmd = self.commands[name](self) - return cmd + return self.commands[name](self) except KeyError: raise UnsupportedCommand(name) + @property + def repository_info(self): + if not self._repository_info: + self._repository_info = self.info() + + return self._repository_info + def _unpack_url(self, url): """ Parses a repository URL and loads its parts into the instance. @@ -83,10 +94,22 @@ class Client(object): return ' '.join(args) - def run_raw_command(self, subcommand, *args): - command = [self.command, self._get_svn_args(), subcommand] + def run_raw_command(self, subcommand, *args, **kwargs): + """ + Runs a raw subversion command and returns the results. + """ + cmd_args = kwargs.pop('cmd_args', '') + command = [self.command, cmd_args, self._get_svn_args(), subcommand] command = ' '.join(command + list(args)) self.logger.debug("Command: %r", command) - return run_command(command) + return run_command(command, **kwargs) + + def get_xml_output(self, subcommand, *args): + """ + Runs a raw command passing the XML flag and returns a pulldom + instance ready for use. + """ + output = self.run_raw_command(subcommand, *args, raw_output=True, cmd_args='--xml') + return pulldom.parseString(output) -- cgit v1.2.3