Skip to content
Snippets Groups Projects
Commit 168467f7 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Remove re warning; Fix test

parent e1601f0b
Branches
Tags
1 merge request!29Issue 32
Pipeline #
...@@ -191,12 +191,12 @@ package-z ...@@ -191,12 +191,12 @@ package-z
] ]
# test linkage to pythonhosted.org # test linkage to pythonhosted.org
server = "https://pythonhosted.org/%s" server = "https://pythonhosted.org/%s/"
os.environ["BOB_DOCUMENTATION_SERVER"] = server os.environ["BOB_DOCUMENTATION_SERVER"] = server
result = link_documentation(additional_packages, stringio(f)) result = link_documentation(additional_packages, stringio(f))
expected = [ expected = [
'https://docs.python.org/%d.%d' % sys.version_info[:2], 'https://docs.python.org/%d.%d/' % sys.version_info[:2],
'http://matplotlib.org', 'http://matplotlib.org/',
'https://setuptools.readthedocs.io/en/latest/', 'https://setuptools.readthedocs.io/en/latest/',
server % 'bob.extension', server % 'bob.extension',
server % 'gridtk', server % 'gridtk',
...@@ -205,12 +205,12 @@ package-z ...@@ -205,12 +205,12 @@ package-z
nose.tools.eq_(sorted(result), sorted(expected)) nose.tools.eq_(sorted(result), sorted(expected))
# test idiap server # test idiap server
server = "https://www.idiap.ch/software/bob/docs/latest/bob/%s/master" server = "https://www.idiap.ch/software/bob/docs/latest/bob/%s/master/"
os.environ["BOB_DOCUMENTATION_SERVER"] = server os.environ["BOB_DOCUMENTATION_SERVER"] = server
result = link_documentation(additional_packages, stringio(f)) result = link_documentation(additional_packages, stringio(f))
expected = [ expected = [
'https://docs.python.org/%d.%d' % sys.version_info[:2], 'https://docs.python.org/%d.%d/' % sys.version_info[:2],
'http://matplotlib.org', 'http://matplotlib.org/',
'https://setuptools.readthedocs.io/en/latest/', 'https://setuptools.readthedocs.io/en/latest/',
server % 'bob.extension', server % 'bob.extension',
server % 'gridtk', server % 'gridtk',
......
...@@ -432,11 +432,12 @@ def link_documentation(additional_packages = ['python', 'numpy'], requirements_f ...@@ -432,11 +432,12 @@ def link_documentation(additional_packages = ['python', 'numpy'], requirements_f
# collect packages are automatically included in the list of indexes # collect packages are automatically included in the list of indexes
packages = [] packages = []
version_re = re.compile(r'\s*[\<\>=]+\s*')
if requirements_file is not None: if requirements_file is not None:
if not isinstance(requirements_file, str) or \ if not isinstance(requirements_file, str) or \
os.path.exists(requirements_file): os.path.exists(requirements_file):
requirements = load_requirements(requirements_file) requirements = load_requirements(requirements_file)
packages += [re.split(r'\s*[\<\>=]*\s*',k)[0] for k in requirements] packages += [version_re.split(k)[0] for k in requirements]
packages += additional_packages packages += additional_packages
...@@ -514,7 +515,10 @@ def link_documentation(additional_packages = ['python', 'numpy'], requirements_f ...@@ -514,7 +515,10 @@ def link_documentation(additional_packages = ['python', 'numpy'], requirements_f
# transforms "(file:///path/to/dir https://example.com/dir| http://bla )" # transforms "(file:///path/to/dir https://example.com/dir| http://bla )"
# into ["file:///path/to/dir", "https://example.com/dir", "http://bla"] # into ["file:///path/to/dir", "https://example.com/dir", "http://bla"]
# so, trim eventual parenthesis/white-spaces and splits by white space or | # so, trim eventual parenthesis/white-spaces and splits by white space or |
if server.strip():
server = re.split(r'[|\s]+', server.strip('() ')) server = re.split(r'[|\s]+', server.strip('() '))
else:
server = []
# check if the packages have documentation on the server # check if the packages have documentation on the server
for p in packages: for p in packages:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment