1212from pulpcore .plugin .models import Remote
1313
1414
15- # todo: why upper case?
1615PYPI_LAST_SERIAL = "X-PYPI-LAST-SERIAL"
1716"""TODO This serial constant is temporary until Python repositories implements serials"""
1817PYPI_SERIAL_CONSTANT = 1000000000
1918
20- PYPI_API_VERSION = "1.0"
19+ SIMPLE_API_VERSION = "1.0"
2120
2221simple_index_template = """<!DOCTYPE html>
2322<html>
2423 <head>
2524 <title>Simple Index</title>
26- <meta name="api -version" value="2" / >
25+ <meta name="pypi:repository -version" content="{SIMPLE_API_VERSION}" >
2726 </head>
2827 <body>
2928 {% for name, canonical_name in projects %}
@@ -131,6 +130,7 @@ def parse_project_metadata(project):
131130 # Release metadata
132131 "packagetype" : project .get ("packagetype" ) or "" ,
133132 "python_version" : project .get ("python_version" ) or "" ,
133+ "metadata_sha256" : "" , # TODO
134134 }
135135
136136
@@ -161,9 +161,9 @@ def parse_metadata(project, version, distribution):
161161 package ["requires_python" ] = distribution .get ("requires_python" ) or package .get (
162162 "requires_python"
163163 ) # noqa: E501
164- package ["yanked " ] = distribution .get ("yanked" ) or False
165- package [ "yanked_reason" ] = distribution . get ( "yanked_reason" ) or " "
166- package [ "sha256_metadata" ] = distribution .get ("data-dist-info-metadata" , {}). get ( "sha256" ) or ""
164+ package ["metadata_sha256 " ] = distribution .get ("data-dist-info-metadata" , {}). get (
165+ "sha256 "
166+ ) or package .get ("metadata_sha256" )
167167
168168 return package
169169
@@ -209,10 +209,6 @@ def artifact_to_python_content_data(filename, artifact, domain=None):
209209 data ["filename" ] = filename
210210 data ["pulp_domain" ] = domain or artifact .pulp_domain
211211 data ["_pulp_domain" ] = data ["pulp_domain" ]
212- # todo: how to get these / should they be here?
213- # data["yanked"] = False
214- # data["yanked_reason"] = ""
215- # data["sha256_metadata"] = ""
216212 return data
217213
218214
@@ -335,7 +331,6 @@ def python_content_to_info(content):
335331 "platform" : content .platform or "" ,
336332 "requires_dist" : json_to_dict (content .requires_dist ) or None ,
337333 "classifiers" : json_to_dict (content .classifiers ) or None ,
338- # todo yanked
339334 "yanked" : False , # These are no longer used on PyPI, but are still present
340335 "yanked_reason" : None ,
341336 # New core metadata (Version 2.1, 2.2, 2.4)
@@ -406,7 +401,6 @@ def find_artifact():
406401 "upload_time" : str (content .pulp_created ),
407402 "upload_time_iso_8601" : str (content .pulp_created .isoformat ()),
408403 "url" : url ,
409- # todo yanked
410404 "yanked" : False ,
411405 "yanked_reason" : None ,
412406 }
@@ -429,7 +423,7 @@ def write_simple_detail(project_name, project_packages, streamed=False):
429423def write_simple_index_json (project_names ):
430424 """Writes the simple index in JSON format."""
431425 return {
432- "meta" : {"api-version" : PYPI_API_VERSION , "_last-serial" : PYPI_SERIAL_CONSTANT },
426+ "meta" : {"api-version" : SIMPLE_API_VERSION , "_last-serial" : PYPI_SERIAL_CONSTANT },
433427 "projects" : [
434428 {"name" : name , "_last-serial" : PYPI_SERIAL_CONSTANT } for name in project_names
435429 ],
@@ -439,7 +433,7 @@ def write_simple_index_json(project_names):
439433def write_simple_detail_json (project_name , project_packages ):
440434 """Writes the simple detail page in JSON format."""
441435 return {
442- "meta" : {"api-version" : PYPI_API_VERSION , "_last-serial" : PYPI_SERIAL_CONSTANT },
436+ "meta" : {"api-version" : SIMPLE_API_VERSION , "_last-serial" : PYPI_SERIAL_CONSTANT },
443437 "name" : canonicalize_name (project_name ),
444438 "files" : [
445439 {
@@ -450,23 +444,17 @@ def write_simple_detail_json(project_name, project_packages):
450444 "requires_python" : package ["requires_python" ] or None ,
451445 # data-dist-info-metadata is deprecated alias for core-metadata
452446 "data-dist-info-metadata" : (
453- {"sha256" : package ["sha256_metadata " ]} if package ["sha256_metadata " ] else False
447+ {"sha256" : package ["metadata_sha256 " ]} if package ["metadata_sha256 " ] else False
454448 ),
455- "yanked" : (
456- package ["yanked_reason" ]
457- if package ["yanked" ] and package ["yanked_reason" ]
458- else package ["yanked" ]
459- ),
460- # gpg-sig (not in warehouse)
461- # todo (from new PEPs):
462- # size (v1.1, PEP 700)
463- # upload-time (v1.1, PEP 700)
449+ # yanked and yanked_reason are not implemented because they are mutable
450+ # TODO in the future:
451+ # size, upload-time (v1.1, PEP 700)
464452 # core-metadata (PEP 7.14)
465453 # provenance (v1.3, PEP 740)
466454 }
467455 for package in project_packages
468456 ],
469- # todo (from new PEPs) :
457+ # TODO in the future :
470458 # versions (v1.1, PEP 700)
471459 # alternate-locations (v1.2, PEP 708)
472460 # project-status (v1.4, PEP 792 - pypi and docs differ)
0 commit comments