From b1f13dc60d5c0711d5c5e32901824c9da0fd389d Mon Sep 17 00:00:00 2001 From: "Daniel Silverstone (br7vm)" Date: Tue, 28 May 2013 16:15:22 +0000 Subject: 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. --- morphlib/repoaliasresolver.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'morphlib/repoaliasresolver.py') 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[a-z][a-z0-9-]+)' r'=(?P[^#]+)#(?P[^#]+)$') 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. -- cgit v1.2.1