86
86
_register_directory()
88
# This is kept in __init__ so that we don't load lp_api_lite unless the branch
89
# actually matches. That way we can avoid importing extra dependencies like
91
_package_branch = lazy_regex.lazy_compile(
92
r'bazaar.launchpad.net.*?/'
93
r'(?P<user>~[^/]+/)?(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?'
94
r'(?P<project>[^/]+)(?P<branch>/[^/]+)?'
98
def _get_package_branch_info(url):
99
"""Determine the packaging information for this URL.
101
:return: If this isn't a packaging branch, return None. If it is, return
102
(archive, series, project)
106
m = _package_branch.search(url)
109
archive, series, project, user = m.group('archive', 'series',
111
if series is not None:
112
# series is optional, so the regex includes the extra '/', we don't
113
# want to send that on (it causes Internal Server Errors.)
114
series = series.strip('/')
116
user = user.strip('~/')
117
if user != 'ubuntu-branches':
119
return archive, series, project
122
def _check_is_up_to_date(the_branch):
123
info = _get_package_branch_info(the_branch.base)
126
c = the_branch.get_config_stack()
127
verbosity = c.get('launchpad.packaging_verbosity')
129
trace.mutter('not checking %s because verbosity is turned off'
130
% (the_branch.base,))
132
archive, series, project = info
133
from . import lp_api_lite
134
latest_pub = lp_api_lite.LatestPublication(archive, series, project)
135
lp_api_lite.report_freshness(the_branch, verbosity, latest_pub)
138
def _register_hooks():
139
_mod_branch.Branch.hooks.install_named_hook('open',
140
_check_is_up_to_date, 'package-branch-up-to-date')
146
88
def load_tests(loader, basic_tests, pattern):
152
93
'test_lp_directory',
187
128
topic_registry.register('launchpad',
189
130
'Using Bazaar with Launchpad.net')
191
_mod_config.option_registry.register(
192
_mod_config.Option('launchpad.packaging_verbosity', default=True,
193
from_unicode=_mod_config.bool_from_store,
195
Whether to warn if a UDD package import branch is accessed that is out of date.
197
Setting this option to 'off' will disable verbosity.
199
_mod_config.option_registry.register(
200
_mod_config.Option('launchpad_username', default=None,
201
help="The username to login with when conneting to Launchpad."))