File tree 6 files changed +46
-38
lines changed
6 files changed +46
-38
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ Installation
54
54
.. _tqdm : https://tqdm.github.io
55
55
56
56
57
- Example
58
- =======
57
+ Examples
58
+ ========
59
59
60
60
Get information about a package:
61
61
@@ -88,3 +88,7 @@ Download a package with a tqdm progress bar:
88
88
client.download_package(
89
89
pkg, path = pkg.filename, progress = tqdm_progress_factory(),
90
90
)
91
+
92
+ `See more examples in the docs. `__
93
+
94
+ __ https://pypi-simple.readthedocs.io/en/stable/examples.html
Original file line number Diff line number Diff line change @@ -15,25 +15,28 @@ their metadata "backfilled" in; see
15
15
.. code :: python
16
16
17
17
# Requirements:
18
- # Python 3.8+
19
18
# packaging 23.1+
20
- # pypi_simple 1.3 +
19
+ # pypi_simple 1.5 +
21
20
22
21
from packaging.metadata import parse_email
23
- from pypi_simple import PyPISimple
22
+ from pypi_simple import NoMetadataError, PyPISimple
24
23
25
24
with PyPISimple() as client:
26
25
page = client.get_project_page(" pypi-simple" )
27
26
for pkg in page.packages:
28
- if pkg.has_metadata:
29
- src = client.get_package_metadata(pkg)
30
- md, _ = parse_email(src)
31
- if deps := md.get(" requires_dist" ):
32
- print (f " Dependencies for { pkg.filename} : " )
33
- for d in deps:
34
- print (f " { d} " )
27
+ if pkg.has_metadata is not False :
28
+ try :
29
+ src = client.get_package_metadata(pkg)
30
+ except NoMetadataError:
31
+ print (f " { pkg.filename} : No metadata available " )
35
32
else :
36
- print (f " Dependencies for { pkg.filename} : NONE " )
33
+ md, _ = parse_email(src)
34
+ if deps := md.get(" requires_dist" ):
35
+ print (f " Dependencies for { pkg.filename} : " )
36
+ for d in deps:
37
+ print (f " { d} " )
38
+ else :
39
+ print (f " Dependencies for { pkg.filename} : NONE " )
37
40
else :
38
41
print (f " { pkg.filename} : No metadata available " )
39
42
print ()
Original file line number Diff line number Diff line change @@ -42,8 +42,8 @@ Installation
42
42
.. _tqdm : https://tqdm.github.io
43
43
44
44
45
- Example
46
- =======
45
+ Examples
46
+ ========
47
47
48
48
Get information about a package:
49
49
@@ -77,6 +77,7 @@ Download a package with a tqdm progress bar:
77
77
pkg, path = pkg.filename, progress = tqdm_progress_factory(),
78
78
)
79
79
80
+ :doc: `See more examples in the docs. <examples >`
80
81
81
82
Indices and tables
82
83
==================
Original file line number Diff line number Diff line change @@ -42,13 +42,13 @@ class DistributionPackage:
42
42
#: The type of the package, or `None` if the filename cannot be parsed.
43
43
#: The recognized package types are:
44
44
#:
45
- #: - ``' dumb' ``
46
- #: - ``' egg' ``
47
- #: - ``' msi' ``
48
- #: - ``' rpm' ``
49
- #: - ``' sdist' ``
50
- #: - ``' wheel' ``
51
- #: - ``' wininst' ``
45
+ #: - ``" dumb" ``
46
+ #: - ``" egg" ``
47
+ #: - ``" msi" ``
48
+ #: - ``" rpm" ``
49
+ #: - ``" sdist" ``
50
+ #: - ``" wheel" ``
51
+ #: - ``" wininst" ``
52
52
package_type : Optional [str ]
53
53
54
54
#: A collection of hash digests for the file as a `dict` mapping hash
Original file line number Diff line number Diff line change @@ -326,8 +326,8 @@ def download_package(
326
326
:param bool verify:
327
327
whether to verify the package's digests against the downloaded file
328
328
:param bool keep_on_error:
329
- whether to keep (true) or delete (false) the downloaded file if an
330
- error occurs
329
+ whether to keep (true) or delete (false; default ) the downloaded
330
+ file if an error occurs
331
331
:param progress: a callable for constructing a progress tracker
332
332
:param timeout: optional timeout to pass to the ``requests`` call
333
333
:type timeout: float | tuple[float,float] | None
Original file line number Diff line number Diff line change @@ -88,24 +88,24 @@ def parse_filename(
88
88
spelled the same as they appear in the filename; no normalization is
89
89
performed.
90
90
91
- The package type may be any of the following strings:
91
+ The package type will be one of the following strings:
92
92
93
- - ``' dumb' ``
94
- - ``' egg' ``
95
- - ``' msi' ``
96
- - ``' rpm' ``
97
- - ``' sdist' ``
98
- - ``' wheel' ``
99
- - ``' wininst' ``
93
+ - ``" dumb" ``
94
+ - ``" egg" ``
95
+ - ``" msi" ``
96
+ - ``" rpm" ``
97
+ - ``" sdist" ``
98
+ - ``" wheel" ``
99
+ - ``" wininst" ``
100
100
101
101
Note that some filenames (e.g., :file:`1-2-3.tar.gz`) may be ambiguous as
102
102
to which part is the project name and which is the version. In order to
103
- resolve the ambiguity, the expected value for the project name (*modulo*
104
- normalization) can be supplied as the ``project_name`` argument to the
105
- function . If the filename can be parsed with the given string in the role
106
- of the project name, the results of that parse will be returned; otherwise,
107
- the function will fall back to breaking the project & version apart at an
108
- unspecified point.
103
+ resolve the ambiguity, the expected value for the project name can be
104
+ supplied as the ``project_name`` argument to the function; it need not be
105
+ normalized . If the filename can be parsed with the given string in the
106
+ role of the project name, the results of that parse will be returned;
107
+ otherwise, the function will fall back to breaking the project & version
108
+ apart at an unspecified point.
109
109
110
110
.. versionchanged:: 1.0.0
111
111
You can’t perform that action at this time.
0 commit comments