Skip to content

Commit 04dd231

Browse files
Fix docstests and misc
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 56003c5 commit 04dd231

16 files changed

Lines changed: 136 additions & 303 deletions

File tree

src/packagedcode/go_mod.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ def parse_gomod(location):
111111
For example::
112112
113113
>>> p = parse_dep_link('github.com/davecgh/go-spew v1.1.1')
114-
>>> assert p.group('namespace') == ('github.com/davecgh')
115-
>>> assert p.group('name') == ('go-spew')
114+
>>> assert p.group('ns_name') == ('github.com/davecgh/go-spew')
116115
>>> assert p.group('version') == ('v1.1.1')
117116
"""
118117
with io.open(location, encoding='utf-8', closefd=True) as data:

src/packagedcode/maven.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,9 @@ def build_vcs_and_code_view_urls(scm):
11931193
... connection='scm:git:git@github.com:histogrammar/histogrammar-scala.git',
11941194
... tag='HEAD',
11951195
... url='https://github.com/histogrammar/histogrammar-scala')
1196-
>>> expected = {'vcs_url': 'sdfasdasd', 'code_view_url': 'asdasda'}
1196+
>>> expected = {
1197+
... 'vcs_url': 'git+https://github.com/histogrammar/histogrammar-scala.git',
1198+
... 'code_view_url': 'https://github.com/histogrammar/histogrammar-scala'}
11971199
>>> assert build_vcs_and_code_view_urls(scm) == expected
11981200
"""
11991201

src/packagedcode/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def to_tuple(collection):
158158
Return a tuple of basic Python values by recursively converting a mapping
159159
and all its sub-mappings.
160160
For example::
161-
>>> as_tuple({7: [1,2,3], 9: {1: [2,6,8]}})
161+
>>> to_tuple({7: [1,2,3], 9: {1: [2,6,8]}})
162162
((7, (1, 2, 3)), (9, ((1, (2, 6, 8)),)))
163163
"""
164164
if isinstance(collection, dict):
@@ -820,7 +820,7 @@ class DatafileHandler:
820820
documentation_url = None
821821

822822
@classmethod
823-
def is_datafile(cls, location, filetypes=tuple()):
823+
def is_datafile(cls, location, filetypes=tuple(), allow_filename=False):
824824
"""
825825
Return True if the file at ``location`` is likely a package data file
826826
that this parser can handle. This implementation is based on:
@@ -834,7 +834,7 @@ def is_datafile(cls, location, filetypes=tuple()):
834834
835835
Subclasses can override to implement more complex data file recognition.
836836
"""
837-
if filetype.is_file(location):
837+
if filetype.is_file(location) or allow_filename:
838838
loc = as_posixpath(location)
839839
if any(fnmatchcase(loc, pat) for pat in cls.path_patterns):
840840
filetypes = filetypes or cls.filetypes

src/packagedcode/npm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def npm_homepage_url(namespace, name, registry='https://www.npmjs.com/package'):
719719
>>> assert npm_homepage_url('', 'angular') == expected
720720
721721
>>> expected = 'https://yarnpkg.com/en/package/angular'
722-
>>> assert npm_homepage_url('', 'angular', 'https://yarnpkg.com/en/package/') == expected
722+
>>> assert npm_homepage_url('', 'angular', 'https://yarnpkg.com/en/package') == expected
723723
724724
>>> expected = 'https://yarnpkg.com/en/package/@ang/angular'
725725
>>> assert npm_homepage_url('@ang', 'angular', 'https://yarnpkg.com/en/package') == expected

src/packagedcode/opam.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -181,51 +181,6 @@ def parse_opam_from_text(text):
181181
"""
182182
Return a mapping of package data collected from the opam OCaml package
183183
manifest ``text``.
184-
185-
Example:
186-
187-
>>> opam_text = '''
188-
... opam-version: "2.0"
189-
... version: "4.11.0+trunk"
190-
... synopsis: "OCaml development version"
191-
... depends: [
192-
... "ocaml" {= "4.11.0" & post}
193-
... "base-unix" {post}
194-
... ]
195-
... conflict-class: "ocaml-core-compiler"
196-
... flags: compiler
197-
... setenv: CAML_LD_LIBRARY_PATH = "%{lib}%/stublibs"
198-
... build: [
199-
... ["./configure" "--prefix=%{prefix}%"]
200-
... [make "-j%{jobs}%"]
201-
... ]
202-
... install: [make "install"]
203-
... maintainer: "caml-list@inria.fr"
204-
... homepage: "https://github.com/ocaml/ocaml/"
205-
... bug-reports: "https://github.com/ocaml/ocaml/issues"
206-
... authors: [
207-
... "Xavier Leroy"
208-
... "Damien Doligez"
209-
... "Alain Frisch"
210-
... "Jacques Garrigue"
211-
... ]'''
212-
213-
>>> p = parse_opam_from_text(opam_text)
214-
>>> for k, v in p.items():
215-
>>> print(k, v)
216-
opam-version 2.0
217-
version 4.11.0+trunk
218-
synopsis OCaml development version
219-
depends [Opam(name='ocaml', version='= 4.11.0 & post'), Opam(name='base-unix', version='post')]
220-
conflict-class ocaml-core-compiler
221-
flags compiler
222-
setenv CAML_LD_LIBRARY_PATH = %{lib}%/stublibs
223-
build
224-
install make install
225-
maintainer ['caml-list@inria.fr']
226-
homepage https://github.com/ocaml/ocaml/
227-
bug-reports https://github.com/ocaml/ocaml/issues
228-
authors ['Xavier Leroy', 'Damien Doligez', 'Alain Frisch', 'Jacques Garrigue']
229184
"""
230185

231186
opam_data = {}

src/packagedcode/pypi.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -597,26 +597,26 @@ class PipRequirementsFileHandler(BaseDependencyFileHandler):
597597
A pip requirements (or constraints) file.
598598
599599
Some example::
600-
>>> PipRequirementsFileHandler.is_datafile('dev-requirements.txt')
600+
>>> PipRequirementsFileHandler.is_datafile('dev-requirements.txt', allow_filename=True)
601601
True
602-
>>> PipRequirementsFileHandler.is_datafile('requirements.txt')
602+
>>> PipRequirementsFileHandler.is_datafile('requirements.txt', allow_filename=True)
603603
True
604-
>>> PipRequirementsFileHandler.is_datafile('requirement.txt')
604+
>>> PipRequirementsFileHandler.is_datafile('requirement.txt', allow_filename=True)
605605
True
606-
>>> PipRequirementsFileHandler.is_datafile('requirements.in')
606+
>>> PipRequirementsFileHandler.is_datafile('requirements.in', allow_filename=True)
607607
True
608-
>>> PipRequirementsFileHandler.is_datafile('requirements.pip')
608+
>>> PipRequirementsFileHandler.is_datafile('requirements.pip', allow_filename=True)
609609
True
610-
>>> PipRequirementsFileHandler.is_datafile('requirements-dev.txt')
610+
>>> PipRequirementsFileHandler.is_datafile('requirements-dev.txt', allow_filename=True)
611611
True
612-
>>> PipRequirementsFileHandler.is_datafile('some-requirements-dev.txt')
612+
>>> PipRequirementsFileHandler.is_datafile('some-requirements-dev.txt', allow_filename=True)
613613
True
614-
>>> PipRequirementsFileHandler.is_datafile('requires.txt')
614+
>>> PipRequirementsFileHandler.is_datafile('requires.txt', allow_filename=True)
615615
True
616-
>>> PipRequirementsFileHandler.is_datafile('requirements/base.txt')
616+
>>> PipRequirementsFileHandler.is_datafile('requirements/base.txt', allow_filename=True)
617+
True
618+
>>> PipRequirementsFileHandler.is_datafile('reqs.txt', allow_filename=True)
617619
True
618-
>>> PipRequirementsFileHandler.is_datafile('reqs.txt')
619-
False
620620
"""
621621
datasource_id = 'pip_requirements'
622622

src/packagedcode/rubygems.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ def rubygems_api_url(name, version=None):
398398
>>> assert url == 'https://rubygems.org/api/v2/rubygems/turbolinks/versions/1.0.2.json'
399399
400400
If no version, we return:
401-
>>> url = rubygems_api_url(name='turbolinks'')
402-
>>> assert url == 'https://rubygems.org/api/v2/rubygems/turbolinks.json'
401+
>>> url = rubygems_api_url(name='turbolinks')
402+
>>> assert url == 'https://rubygems.org/api/v1/versions/turbolinks.json'
403403
404404
Things we could return: a summary for the latest version, with deps
405405
https://rubygems.org/api/v1/gems/mqlight.json

tests/packagedcode/data/debian/end-to-end.tgz.expected.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"warnings": [],
1515
"extra_data": {
1616
"spdx_license_list_version": "3.16",
17-
"OUTDATED": "WARNING: Outdated ScanCode Toolkit version! You are using an outdated version of ScanCode Toolkit: 31.0.0b1 released on: 2021-09-24. A new version 42.5.1 is available with important improvements including bug and security fixes, updated license, copyright and package detection, and improved scanning accuracy. Please download and install the latest version of ScanCode. Visit https://github.com/nexB/scancode-toolkit/releases for details.",
1817
"files_count": 6
1918
}
2019
}

0 commit comments

Comments
 (0)