@@ -362,7 +362,12 @@ def fetch_json_release_metadata(name: str, version: str, remotes: set[Remote]) -
362362
363363
364364def python_content_to_json (
365- base_path , content_query , version = None , domain = None , repository_version = None
365+ base_path ,
366+ content_query ,
367+ version = None ,
368+ domain = None ,
369+ repository_version = None ,
370+ yank_markers = None ,
366371):
367372 """
368373 Converts a QuerySet of PythonPackageContent into the PyPi JSON format
@@ -375,6 +380,8 @@ def python_content_to_json(
375380
376381 Returns None if version is specified but not found within content_query
377382 """
383+ if yank_markers is None :
384+ yank_markers = {}
378385 if repository_version :
379386 content_query = content_query .annotate (
380387 active_membership = FilteredRelation (
@@ -386,13 +393,20 @@ def python_content_to_json(
386393 ),
387394 repo_added_time = F ("active_membership__pulp_created" ),
388395 )
389- full_metadata = {"last_serial" : 0 } # For now the serial field isn't supported by Pulp
390- latest_content = latest_content_version (content_query , version )
396+
397+ all_content = list (content_query )
398+ for content in all_content :
399+ content .yanked = content .version in yank_markers
400+ content .yanked_reason = yank_markers .get (content .version )
401+
402+ latest_content = latest_content_version (all_content , version )
391403 if not latest_content :
392404 return None
393- full_metadata .update ({"info" : python_content_to_info (latest_content [0 ])})
394- full_metadata .update ({"releases" : python_content_to_releases (content_query , base_path , domain )})
395- full_metadata .update ({"urls" : python_content_to_urls (latest_content , base_path , domain )})
405+
406+ full_metadata = {"last_serial" : 0 } # For now the serial field isn't supported by Pulp
407+ full_metadata ["info" ] = python_content_to_info (latest_content [0 ])
408+ full_metadata ["releases" ] = python_content_to_releases (all_content , base_path , domain )
409+ full_metadata ["urls" ] = python_content_to_urls (latest_content , base_path , domain )
396410 return full_metadata
397411
398412
@@ -462,8 +476,8 @@ def python_content_to_info(content):
462476 "platform" : content .platform or "" ,
463477 "requires_dist" : json_to_dict (content .requires_dist ) or None ,
464478 "classifiers" : json_to_dict (content .classifiers ) or None ,
465- "yanked" : False , # These are no longer used on PyPI, but are still present
466- "yanked_reason" : None ,
479+ "yanked" : content . yanked ,
480+ "yanked_reason" : content . yanked_reason ,
467481 # New core metadata (Version 2.1, 2.2, 2.4)
468482 "provides_extras" : json_to_dict (content .provides_extras ) or None ,
469483 "dynamic" : json_to_dict (content .dynamic ) or None ,
@@ -472,13 +486,13 @@ def python_content_to_info(content):
472486 }
473487
474488
475- def python_content_to_releases (content_query , base_path , domain = None ):
489+ def python_content_to_releases (contents , base_path , domain = None ):
476490 """
477- Takes a QuerySet of PythonPackageContent and returns a dictionary of releases
491+ Takes a list of PythonPackageContent and returns a dictionary of releases
478492 with each key being a version and value being a list of content for that version of the package
479493 """
480494 releases = defaultdict (lambda : [])
481- for content in content_query :
495+ for content in contents :
482496 releases [content .version ].append (
483497 python_content_to_download_info (content , base_path , domain )
484498 )
@@ -535,8 +549,8 @@ def find_artifact():
535549 (getattr (content , "repo_added_time" , None ) or content .pulp_created ).isoformat ()
536550 ),
537551 "url" : url ,
538- "yanked" : False ,
539- "yanked_reason" : None ,
552+ "yanked" : content . yanked ,
553+ "yanked_reason" : content . yanked_reason ,
540554 }
541555
542556
0 commit comments