|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 | import argparse |
17 | | -import fnmatch |
18 | 17 | import logging |
19 | | -import os.path |
20 | | -from typing import Dict, List, NamedTuple, cast |
| 18 | +from typing import Dict, List, cast |
21 | 19 |
|
22 | 20 | import requests |
23 | 21 | from rich import print |
@@ -110,44 +108,6 @@ def _make_package( |
110 | 108 | return package |
111 | 109 |
|
112 | 110 |
|
113 | | -class Inputs(NamedTuple): |
114 | | - """Represents structured user inputs.""" |
115 | | - |
116 | | - dists: List[str] |
117 | | - signatures: Dict[str, str] |
118 | | - attestations_by_dist: Dict[str, List[str]] |
119 | | - |
120 | | - |
121 | | -def _split_inputs( |
122 | | - inputs: List[str], |
123 | | -) -> Inputs: |
124 | | - """ |
125 | | - Split the unstructured list of input files provided by the user into groups. |
126 | | -
|
127 | | - Three groups are returned: upload files (i.e. dists), signatures, and attestations. |
128 | | -
|
129 | | - Upload files are returned as a linear list, signatures are returned as a |
130 | | - dict of ``basename -> path``, and attestations are returned as a dict of |
131 | | - ``dist-path -> [attestation-path]``. |
132 | | - """ |
133 | | - signatures = {os.path.basename(i): i for i in fnmatch.filter(inputs, "*.asc")} |
134 | | - attestations = fnmatch.filter(inputs, "*.*.attestation") |
135 | | - dists = [ |
136 | | - dist |
137 | | - for dist in inputs |
138 | | - if dist not in (set(signatures.values()) | set(attestations)) |
139 | | - ] |
140 | | - |
141 | | - attestations_by_dist = {} |
142 | | - for dist in dists: |
143 | | - dist_basename = os.path.basename(dist) |
144 | | - attestations_by_dist[dist] = [ |
145 | | - a for a in attestations if os.path.basename(a).startswith(dist_basename) |
146 | | - ] |
147 | | - |
148 | | - return Inputs(dists, signatures, attestations_by_dist) |
149 | | - |
150 | | - |
151 | 111 | def upload(upload_settings: settings.Settings, dists: List[str]) -> None: |
152 | 112 | """Upload one or more distributions to a repository, and display the progress. |
153 | 113 |
|
@@ -187,7 +147,7 @@ def upload(upload_settings: settings.Settings, dists: List[str]) -> None: |
187 | 147 |
|
188 | 148 | dists = commands._find_dists(dists) |
189 | 149 | # Determine if the user has passed in pre-signed distributions or any attestations. |
190 | | - uploads, signatures, attestations_by_dist = _split_inputs(dists) |
| 150 | + uploads, signatures, attestations_by_dist = commands._split_inputs(dists) |
191 | 151 |
|
192 | 152 | print(f"Uploading distributions to {utils.sanitize_url(repository_url)}") |
193 | 153 |
|
|
0 commit comments