summaryrefslogtreecommitdiff
path: root/morphlib/repoaliasresolver.py
diff options
context:
space:
mode:
authorDaniel Silverstone (br7vm) <daniel.silverstone@codethink.co.uk>2013-05-28 16:15:22 +0000
committerDaniel Silverstone (br7vm) <daniel.silverstone@codethink.co.uk>2013-05-28 16:15:22 +0000
commitb1f13dc60d5c0711d5c5e32901824c9da0fd389d (patch)
treee841e9b74ac2d158e1ecf05a9c825bac7f165635 /morphlib/repoaliasresolver.py
parentad28474a0334e60e9036050c625b4a2341f33462 (diff)
downloadmorph-b1f13dc60d5c0711d5c5e32901824c9da0fd389d.tar.gz
REPOALIAS: Restructure debugging
Restructure the repo alias debugging so we do not flood the log with a lot of non-useful repo alias debug, instead log a single line indicating expansions which occur.
Diffstat (limited to 'morphlib/repoaliasresolver.py')
-rw-r--r--morphlib/repoaliasresolver.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/morphlib/repoaliasresolver.py b/morphlib/repoaliasresolver.py
index 5ade0639..bc759dd4 100644
--- a/morphlib/repoaliasresolver.py
+++ b/morphlib/repoaliasresolver.py
@@ -48,14 +48,11 @@ class RepoAliasResolver(object):
alias_pattern = (r'^(?P<prefix>[a-z][a-z0-9-]+)'
r'=(?P<pullpat>[^#]+)#(?P<pushpat>[^#]+)$')
for alias in aliases:
- logging.debug('expanding: alias="%s"' % alias)
m = re.match(alias_pattern, alias)
- logging.debug('expanding: m=%s' % repr(m))
if not m:
logging.warning('Alias %s is malformed' % alias)
continue
prefix = m.group('prefix')
- logging.debug('expanding: prefix group=%s' % prefix)
self.aliases[prefix] = RepoAlias(alias, prefix, m.group('pullpat'),
m.group('pushpat'))
@@ -80,27 +77,23 @@ class RepoAliasResolver(object):
return sorted(known_aliases)
def _expand_reponame(self, reponame, patname):
- logging.debug('expanding: reponame=%s' % reponame)
- logging.debug('expanding: patname=%s' % patname)
-
prefix, suffix = self._split_reponame(reponame)
- logging.debug('expanding: prefix=%s' % prefix)
- logging.debug('expanding: suffix=%s' % suffix)
# There was no prefix.
if prefix is None:
- logging.debug('expanding: no prefix')
- return reponame
-
- if prefix not in self.aliases:
+ result = reponame
+ elif prefix not in self.aliases:
# Unknown prefix. Which means it may be a real URL instead.
# Let the caller deal with it.
- logging.debug('expanding: unknown prefix')
- return reponame
+ result = reponame
+ else:
+ pat = getattr(self.aliases[prefix], patname)
+ result = self._apply_url_pattern(pat, suffix)
- pat = getattr(self.aliases[prefix], patname)
- return self._apply_url_pattern(pat, suffix)
+ logging.debug("Expansion of %s for %s yielded: %s" %
+ (reponame, patname, result))
+ return result
def _split_reponame(self, reponame):
'''Split reponame into prefix and suffix.