pulp-python 3.11.8__py3-none-any.whl → 3.11.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. pulp_python/__init__.py +1 -1
  2. pulp_python/app/__init__.py +1 -1
  3. pulp_python/app/fields.py +1 -1
  4. pulp_python/app/modelresource.py +1 -0
  5. pulp_python/app/models.py +6 -5
  6. pulp_python/app/pypi/serializers.py +12 -10
  7. pulp_python/app/pypi/views.py +70 -55
  8. pulp_python/app/serializers.py +192 -115
  9. pulp_python/app/settings.py +1 -1
  10. pulp_python/app/tasks/publish.py +24 -25
  11. pulp_python/app/tasks/sync.py +18 -32
  12. pulp_python/app/tasks/upload.py +11 -12
  13. pulp_python/app/urls.py +6 -6
  14. pulp_python/app/utils.py +38 -36
  15. pulp_python/app/viewsets.py +42 -44
  16. pulp_python/tests/functional/api/test_auto_publish.py +5 -3
  17. pulp_python/tests/functional/api/test_consume_content.py +9 -11
  18. pulp_python/tests/functional/api/test_crud_content_unit.py +17 -22
  19. pulp_python/tests/functional/api/test_crud_publications.py +13 -15
  20. pulp_python/tests/functional/api/test_crud_remotes.py +11 -14
  21. pulp_python/tests/functional/api/test_download_content.py +10 -17
  22. pulp_python/tests/functional/api/test_export_import.py +7 -8
  23. pulp_python/tests/functional/api/test_full_mirror.py +21 -19
  24. pulp_python/tests/functional/api/test_pypi_apis.py +23 -27
  25. pulp_python/tests/functional/api/test_sync.py +41 -58
  26. pulp_python/tests/functional/conftest.py +14 -4
  27. pulp_python/tests/functional/constants.py +25 -39
  28. pulp_python/tests/functional/utils.py +34 -22
  29. pulp_python/tests/upgrade/post/test_publish.py +11 -10
  30. pulp_python/tests/upgrade/pre/test_publish.py +12 -11
  31. {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/METADATA +1 -1
  32. pulp_python-3.11.9.dist-info/RECORD +61 -0
  33. {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/WHEEL +1 -1
  34. pulp_python-3.11.8.dist-info/RECORD +0 -61
  35. {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/entry_points.txt +0 -0
  36. {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/licenses/LICENSE +0 -0
  37. {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  from gettext import gettext as _
2
+
2
3
  from django.conf import settings
3
4
  from packaging.requirements import Requirement
4
5
  from rest_framework import serializers
@@ -6,8 +7,8 @@ from rest_framework import serializers
6
7
  from pulpcore.plugin import models as core_models
7
8
  from pulpcore.plugin import serializers as core_serializers
8
9
 
9
- from pulp_python.app import models as python_models
10
10
  from pulp_python.app import fields
11
+ from pulp_python.app import models as python_models
11
12
  from pulp_python.app.utils import get_project_metadata_from_artifact, parse_project_metadata
12
13
 
13
14
 
@@ -44,15 +45,14 @@ class PythonDistributionSerializer(core_serializers.DistributionSerializer):
44
45
  )
45
46
  base_url = serializers.SerializerMethodField(read_only=True)
46
47
  allow_uploads = serializers.BooleanField(
47
- default=True,
48
- help_text=_("Allow packages to be uploaded to this index.")
48
+ default=True, help_text=_("Allow packages to be uploaded to this index.")
49
49
  )
50
50
  remote = core_serializers.DetailRelatedField(
51
51
  required=False,
52
- help_text=_('Remote that can be used to fetch content when using pull-through caching.'),
52
+ help_text=_("Remote that can be used to fetch content when using pull-through caching."),
53
53
  view_name_pattern=r"remotes(-.*/.*)?-detail",
54
54
  queryset=core_models.Remote.objects.all(),
55
- allow_null=True
55
+ allow_null=True,
56
56
  )
57
57
 
58
58
  def get_base_url(self, obj):
@@ -61,7 +61,9 @@ class PythonDistributionSerializer(core_serializers.DistributionSerializer):
61
61
 
62
62
  class Meta:
63
63
  fields = core_serializers.DistributionSerializer.Meta.fields + (
64
- 'publication', "allow_uploads", "remote"
64
+ "publication",
65
+ "allow_uploads",
66
+ "remote",
65
67
  )
66
68
  model = python_models.PythonDistribution
67
69
 
@@ -72,126 +74,162 @@ class PythonPackageContentSerializer(core_serializers.SingleArtifactContentUploa
72
74
  """
73
75
 
74
76
  filename = serializers.CharField(
75
- help_text=_('The name of the distribution package, usually of the format:'
76
- ' {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}'
77
- '-{platform tag}.{packagetype}'),
77
+ help_text=_(
78
+ "The name of the distribution package, usually of the format:"
79
+ " {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}"
80
+ "-{platform tag}.{packagetype}"
81
+ ),
78
82
  read_only=True,
79
83
  )
80
84
  packagetype = serializers.CharField(
81
- help_text=_('The type of the distribution package '
82
- '(e.g. sdist, bdist_wheel, bdist_egg, etc)'),
85
+ help_text=_(
86
+ "The type of the distribution package (e.g. sdist, bdist_wheel, bdist_egg, etc)"
87
+ ),
83
88
  read_only=True,
84
89
  )
85
90
  name = serializers.CharField(
86
- help_text=_('The name of the python project.'),
91
+ help_text=_("The name of the python project."),
87
92
  read_only=True,
88
93
  )
89
94
  version = serializers.CharField(
90
- help_text=_('The packages version number.'),
95
+ help_text=_("The packages version number."),
91
96
  read_only=True,
92
97
  )
93
98
  sha256 = serializers.CharField(
94
- default='',
95
- help_text=_('The SHA256 digest of this package.'),
99
+ default="",
100
+ help_text=_("The SHA256 digest of this package."),
96
101
  )
97
102
  metadata_version = serializers.CharField(
98
- help_text=_('Version of the file format'),
103
+ help_text=_("Version of the file format"),
99
104
  read_only=True,
100
105
  )
101
106
  summary = serializers.CharField(
102
- required=False, allow_blank=True,
103
- help_text=_('A one-line summary of what the package does.')
107
+ required=False,
108
+ allow_blank=True,
109
+ help_text=_("A one-line summary of what the package does."),
104
110
  )
105
111
  description = serializers.CharField(
106
- required=False, allow_blank=True,
107
- help_text=_('A longer description of the package that can run to several paragraphs.')
112
+ required=False,
113
+ allow_blank=True,
114
+ help_text=_("A longer description of the package that can run to several paragraphs."),
108
115
  )
109
116
  description_content_type = serializers.CharField(
110
- required=False, allow_blank=True,
111
- help_text=_('A string stating the markup syntax (if any) used in the distribution’s'
112
- ' description, so that tools can intelligently render the description.')
117
+ required=False,
118
+ allow_blank=True,
119
+ help_text=_(
120
+ "A string stating the markup syntax (if any) used in the distribution’s"
121
+ " description, so that tools can intelligently render the description."
122
+ ),
113
123
  )
114
124
  keywords = serializers.CharField(
115
- required=False, allow_blank=True,
116
- help_text=_('Additional keywords to be used to assist searching for the '
117
- 'package in a larger catalog.')
125
+ required=False,
126
+ allow_blank=True,
127
+ help_text=_(
128
+ "Additional keywords to be used to assist searching for the "
129
+ "package in a larger catalog."
130
+ ),
118
131
  )
119
132
  home_page = serializers.CharField(
120
- required=False, allow_blank=True,
121
- help_text=_('The URL for the package\'s home page.')
133
+ required=False, allow_blank=True, help_text=_("The URL for the package's home page.")
122
134
  )
123
135
  download_url = serializers.CharField(
124
- required=False, allow_blank=True,
125
- help_text=_('Legacy field denoting the URL from which this package can be downloaded.')
136
+ required=False,
137
+ allow_blank=True,
138
+ help_text=_("Legacy field denoting the URL from which this package can be downloaded."),
126
139
  )
127
140
  author = serializers.CharField(
128
- required=False, allow_blank=True,
129
- help_text=_('Text containing the author\'s name. Contact information can also be added,'
130
- ' separated with newlines.')
141
+ required=False,
142
+ allow_blank=True,
143
+ help_text=_(
144
+ "Text containing the author's name. Contact information can also be added,"
145
+ " separated with newlines."
146
+ ),
131
147
  )
132
148
  author_email = serializers.CharField(
133
- required=False, allow_blank=True,
134
- help_text=_('The author\'s e-mail address. ')
149
+ required=False, allow_blank=True, help_text=_("The author's e-mail address. ")
135
150
  )
136
151
  maintainer = serializers.CharField(
137
- required=False, allow_blank=True,
138
- help_text=_('The maintainer\'s name at a minimum; '
139
- 'additional contact information may be provided.')
152
+ required=False,
153
+ allow_blank=True,
154
+ help_text=_(
155
+ "The maintainer's name at a minimum; additional contact information may be provided."
156
+ ),
140
157
  )
141
158
  maintainer_email = serializers.CharField(
142
- required=False, allow_blank=True,
143
- help_text=_('The maintainer\'s e-mail address.')
159
+ required=False, allow_blank=True, help_text=_("The maintainer's e-mail address.")
144
160
  )
145
161
  license = serializers.CharField(
146
- required=False, allow_blank=True,
147
- help_text=_('Text indicating the license covering the distribution')
162
+ required=False,
163
+ allow_blank=True,
164
+ help_text=_("Text indicating the license covering the distribution"),
148
165
  )
149
166
  requires_python = serializers.CharField(
150
- required=False, allow_blank=True,
151
- help_text=_('The Python version(s) that the distribution is guaranteed to be '
152
- 'compatible with.')
167
+ required=False,
168
+ allow_blank=True,
169
+ help_text=_(
170
+ "The Python version(s) that the distribution is guaranteed to be compatible with."
171
+ ),
153
172
  )
154
173
  project_url = serializers.CharField(
155
- required=False, allow_blank=True,
156
- help_text=_('A browsable URL for the project and a label for it, separated by a comma.')
174
+ required=False,
175
+ allow_blank=True,
176
+ help_text=_("A browsable URL for the project and a label for it, separated by a comma."),
157
177
  )
158
178
  project_urls = fields.JSONObjectField(
159
- required=False, default=dict,
160
- help_text=_('A dictionary of labels and URLs for the project.')
179
+ required=False,
180
+ default=dict,
181
+ help_text=_("A dictionary of labels and URLs for the project."),
161
182
  )
162
183
  platform = serializers.CharField(
163
- required=False, allow_blank=True,
164
- help_text=_('A comma-separated list of platform specifications, '
165
- 'summarizing the operating systems supported by the package.')
184
+ required=False,
185
+ allow_blank=True,
186
+ help_text=_(
187
+ "A comma-separated list of platform specifications, "
188
+ "summarizing the operating systems supported by the package."
189
+ ),
166
190
  )
167
191
  supported_platform = serializers.CharField(
168
- required=False, allow_blank=True,
169
- help_text=_('Field to specify the OS and CPU for which the binary package was compiled. ')
192
+ required=False,
193
+ allow_blank=True,
194
+ help_text=_("Field to specify the OS and CPU for which the binary package was compiled. "),
170
195
  )
171
196
  requires_dist = fields.JSONObjectField(
172
- required=False, default=list,
173
- help_text=_('A JSON list containing names of some other distutils project '
174
- 'required by this distribution.')
197
+ required=False,
198
+ default=list,
199
+ help_text=_(
200
+ "A JSON list containing names of some other distutils project "
201
+ "required by this distribution."
202
+ ),
175
203
  )
176
204
  provides_dist = fields.JSONObjectField(
177
- required=False, default=list,
178
- help_text=_('A JSON list containing names of a Distutils project which is contained'
179
- ' within this distribution.')
205
+ required=False,
206
+ default=list,
207
+ help_text=_(
208
+ "A JSON list containing names of a Distutils project which is contained"
209
+ " within this distribution."
210
+ ),
180
211
  )
181
212
  obsoletes_dist = fields.JSONObjectField(
182
- required=False, default=list,
183
- help_text=_('A JSON list containing names of a distutils project\'s distribution which '
184
- 'this distribution renders obsolete, meaning that the two projects should not '
185
- 'be installed at the same time.')
213
+ required=False,
214
+ default=list,
215
+ help_text=_(
216
+ "A JSON list containing names of a distutils project's distribution which "
217
+ "this distribution renders obsolete, meaning that the two projects should not "
218
+ "be installed at the same time."
219
+ ),
186
220
  )
187
221
  requires_external = fields.JSONObjectField(
188
- required=False, default=list,
189
- help_text=_('A JSON list containing some dependency in the system that the distribution '
190
- 'is to be used.')
222
+ required=False,
223
+ default=list,
224
+ help_text=_(
225
+ "A JSON list containing some dependency in the system that the distribution "
226
+ "is to be used."
227
+ ),
191
228
  )
192
229
  classifiers = fields.JSONObjectField(
193
- required=False, default=list,
194
- help_text=_('A JSON list containing classification values for a Python package.')
230
+ required=False,
231
+ default=list,
232
+ help_text=_("A JSON list containing classification values for a Python package."),
195
233
  )
196
234
 
197
235
  def deferred_validate(self, data):
@@ -210,29 +248,33 @@ class PythonPackageContentSerializer(core_serializers.SingleArtifactContentUploa
210
248
  try:
211
249
  filename = data["relative_path"]
212
250
  except KeyError:
213
- raise serializers.ValidationError(detail={"relative_path": _('This field is required')})
251
+ raise serializers.ValidationError(detail={"relative_path": _("This field is required")})
214
252
 
215
253
  artifact = data["artifact"]
216
254
  try:
217
255
  metadata = get_project_metadata_from_artifact(filename, artifact)
218
256
  except ValueError:
219
- raise serializers.ValidationError(_(
220
- "Extension on {} is not a valid python extension "
221
- "(.whl, .exe, .egg, .tar.gz, .tar.bz2, .zip)").format(filename)
257
+ raise serializers.ValidationError(
258
+ _(
259
+ "Extension on {} is not a valid python extension "
260
+ "(.whl, .exe, .egg, .tar.gz, .tar.bz2, .zip)"
261
+ ).format(filename)
222
262
  )
223
263
 
224
264
  if data.get("sha256") and data["sha256"] != artifact.sha256:
225
265
  raise serializers.ValidationError(
226
- detail={"sha256": _(
227
- "The uploaded artifact's sha256 checksum does not match the one provided"
228
- )}
266
+ detail={
267
+ "sha256": _(
268
+ "The uploaded artifact's sha256 checksum does not match the one provided"
269
+ )
270
+ }
229
271
  )
230
272
 
231
273
  _data = parse_project_metadata(vars(metadata))
232
- _data['packagetype'] = metadata.packagetype
233
- _data['version'] = metadata.version
234
- _data['filename'] = filename
235
- _data['sha256'] = artifact.sha256
274
+ _data["packagetype"] = metadata.packagetype
275
+ _data["version"] = metadata.version
276
+ _data["filename"] = filename
277
+ _data["sha256"] = artifact.sha256
236
278
 
237
279
  data.update(_data)
238
280
 
@@ -244,11 +286,33 @@ class PythonPackageContentSerializer(core_serializers.SingleArtifactContentUploa
244
286
 
245
287
  class Meta:
246
288
  fields = core_serializers.SingleArtifactContentUploadSerializer.Meta.fields + (
247
- 'filename', 'packagetype', 'name', 'version', 'sha256', 'metadata_version', 'summary',
248
- 'description', 'description_content_type', 'keywords', 'home_page', 'download_url',
249
- 'author', 'author_email', 'maintainer', 'maintainer_email', 'license',
250
- 'requires_python', 'project_url', 'project_urls', 'platform', 'supported_platform',
251
- 'requires_dist', 'provides_dist', 'obsoletes_dist', 'requires_external', 'classifiers'
289
+ "filename",
290
+ "packagetype",
291
+ "name",
292
+ "version",
293
+ "sha256",
294
+ "metadata_version",
295
+ "summary",
296
+ "description",
297
+ "description_content_type",
298
+ "keywords",
299
+ "home_page",
300
+ "download_url",
301
+ "author",
302
+ "author_email",
303
+ "maintainer",
304
+ "maintainer_email",
305
+ "license",
306
+ "requires_python",
307
+ "project_url",
308
+ "project_urls",
309
+ "platform",
310
+ "supported_platform",
311
+ "requires_dist",
312
+ "provides_dist",
313
+ "obsoletes_dist",
314
+ "requires_external",
315
+ "classifiers",
252
316
  )
253
317
  model = python_models.PythonPackageContent
254
318
 
@@ -260,7 +324,11 @@ class MinimalPythonPackageContentSerializer(PythonPackageContentSerializer):
260
324
 
261
325
  class Meta:
262
326
  fields = core_serializers.SingleArtifactContentUploadSerializer.Meta.fields + (
263
- 'filename', 'packagetype', 'name', 'version', 'sha256',
327
+ "filename",
328
+ "packagetype",
329
+ "name",
330
+ "version",
331
+ "sha256",
264
332
  )
265
333
  model = python_models.PythonPackageContent
266
334
 
@@ -284,47 +352,49 @@ class PythonRemoteSerializer(core_serializers.RemoteSerializer):
284
352
  child=serializers.CharField(allow_blank=False),
285
353
  required=False,
286
354
  allow_empty=True,
287
- help_text=_(
288
- "A list containing project specifiers for Python packages to include."
289
- ),
355
+ help_text=_("A list containing project specifiers for Python packages to include."),
290
356
  )
291
357
  excludes = serializers.ListField(
292
358
  child=serializers.CharField(allow_blank=False),
293
359
  required=False,
294
360
  allow_empty=True,
295
- help_text=_(
296
- "A list containing project specifiers for Python packages to exclude."
297
- ),
361
+ help_text=_("A list containing project specifiers for Python packages to exclude."),
298
362
  )
299
363
  prereleases = serializers.BooleanField(
300
- required=False,
301
- help_text=_('Whether or not to include pre-release packages in the sync.')
364
+ required=False, help_text=_("Whether or not to include pre-release packages in the sync.")
302
365
  )
303
366
  policy = serializers.ChoiceField(
304
- help_text=_("The policy to use when downloading content. The possible values include: "
305
- "'immediate', 'on_demand', and 'streamed'. 'on_demand' is the default."),
367
+ help_text=_(
368
+ "The policy to use when downloading content. The possible values include: "
369
+ "'immediate', 'on_demand', and 'streamed'. 'on_demand' is the default."
370
+ ),
306
371
  choices=core_models.Remote.POLICY_CHOICES,
307
- default=core_models.Remote.ON_DEMAND
372
+ default=core_models.Remote.ON_DEMAND,
308
373
  )
309
374
  package_types = MultipleChoiceArrayField(
310
375
  required=False,
311
- help_text=_("The package types to sync for Python content. Leave blank to get every"
312
- "package type."),
376
+ help_text=_(
377
+ "The package types to sync for Python content. Leave blank to get everypackage type."
378
+ ),
313
379
  choices=python_models.PACKAGE_TYPES,
314
- default=list
380
+ default=list,
315
381
  )
316
382
  keep_latest_packages = serializers.IntegerField(
317
383
  required=False,
318
- help_text=_("The amount of latest versions of a package to keep on sync, includes"
319
- "pre-releases if synced. Default 0 keeps all versions."),
320
- default=0
384
+ help_text=_(
385
+ "The amount of latest versions of a package to keep on sync, includes"
386
+ "pre-releases if synced. Default 0 keeps all versions."
387
+ ),
388
+ default=0,
321
389
  )
322
390
  exclude_platforms = MultipleChoiceArrayField(
323
391
  required=False,
324
- help_text=_("List of platforms to exclude syncing Python packages for. Possible values"
325
- "include: windows, macos, freebsd, and linux."),
392
+ help_text=_(
393
+ "List of platforms to exclude syncing Python packages for. Possible values"
394
+ "include: windows, macos, freebsd, and linux."
395
+ ),
326
396
  choices=python_models.PLATFORMS,
327
- default=list
397
+ default=list,
328
398
  )
329
399
 
330
400
  def validate_includes(self, value):
@@ -334,7 +404,7 @@ class PythonRemoteSerializer(core_serializers.RemoteSerializer):
334
404
  Requirement(pkg)
335
405
  except ValueError as ve:
336
406
  raise serializers.ValidationError(
337
- _("includes specifier {} is invalid. {}".format(pkg, ve))
407
+ _("includes specifier {} is invalid. {}").format(pkg, ve)
338
408
  )
339
409
  return value
340
410
 
@@ -345,13 +415,17 @@ class PythonRemoteSerializer(core_serializers.RemoteSerializer):
345
415
  Requirement(pkg)
346
416
  except ValueError as ve:
347
417
  raise serializers.ValidationError(
348
- _("excludes specifier {} is invalid. {}".format(pkg, ve))
418
+ _("excludes specifier {} is invalid. {}").format(pkg, ve)
349
419
  )
350
420
  return value
351
421
 
352
422
  class Meta:
353
423
  fields = core_serializers.RemoteSerializer.Meta.fields + (
354
- "includes", "excludes", "prereleases", "package_types", "keep_latest_packages",
424
+ "includes",
425
+ "excludes",
426
+ "prereleases",
427
+ "package_types",
428
+ "keep_latest_packages",
355
429
  "exclude_platforms",
356
430
  )
357
431
  model = python_models.PythonRemote
@@ -373,10 +447,12 @@ class PythonBanderRemoteSerializer(serializers.Serializer):
373
447
  )
374
448
 
375
449
  policy = serializers.ChoiceField(
376
- help_text=_("The policy to use when downloading content. The possible values include: "
377
- "'immediate', 'on_demand', and 'streamed'. 'on_demand' is the default."),
450
+ help_text=_(
451
+ "The policy to use when downloading content. The possible values include: "
452
+ "'immediate', 'on_demand', and 'streamed'. 'on_demand' is the default."
453
+ ),
378
454
  choices=core_models.Remote.POLICY_CHOICES,
379
- default=core_models.Remote.ON_DEMAND
455
+ default=core_models.Remote.ON_DEMAND,
380
456
  )
381
457
 
382
458
 
@@ -386,8 +462,9 @@ class PythonPublicationSerializer(core_serializers.PublicationSerializer):
386
462
  """
387
463
 
388
464
  distributions = core_serializers.DetailRelatedField(
389
- help_text=_('This publication is currently being hosted as configured by these '
390
- 'distributions.'),
465
+ help_text=_(
466
+ "This publication is currently being hosted as configured by these distributions."
467
+ ),
391
468
  source="distribution_set",
392
469
  view_name="pythondistributions-detail",
393
470
  many=True,
@@ -395,5 +472,5 @@ class PythonPublicationSerializer(core_serializers.PublicationSerializer):
395
472
  )
396
473
 
397
474
  class Meta:
398
- fields = core_serializers.PublicationSerializer.Meta.fields + ('distributions',)
475
+ fields = core_serializers.PublicationSerializer.Meta.fields + ("distributions",)
399
476
  model = python_models.PythonPublication
@@ -1,4 +1,4 @@
1
1
  import socket
2
2
 
3
3
  PYTHON_GROUP_UPLOADS = False
4
- PYPI_API_HOSTNAME = 'https://' + socket.getfqdn()
4
+ PYPI_API_HOSTNAME = "https://" + socket.getfqdn()
@@ -1,6 +1,6 @@
1
- from gettext import gettext as _
2
1
  import logging
3
2
  import os
3
+ from gettext import gettext as _
4
4
 
5
5
  from django.core.files import File
6
6
  from packaging.utils import canonicalize_name
@@ -8,8 +8,7 @@ from packaging.utils import canonicalize_name
8
8
  from pulpcore.plugin import models
9
9
 
10
10
  from pulp_python.app import models as python_models
11
- from pulp_python.app.utils import write_simple_index, write_simple_detail
12
-
11
+ from pulp_python.app.utils import write_simple_detail, write_simple_index
13
12
 
14
13
  log = logging.getLogger(__name__)
15
14
 
@@ -24,15 +23,17 @@ def publish(repository_version_pk):
24
23
  """
25
24
  repository_version = models.RepositoryVersion.objects.get(pk=repository_version_pk)
26
25
 
27
- log.info(_('Publishing: repository={repo}, version={version}').format(
28
- repo=repository_version.repository.name,
29
- version=repository_version.number,
30
- ))
26
+ log.info(
27
+ _("Publishing: repository={repo}, version={version}").format(
28
+ repo=repository_version.repository.name,
29
+ version=repository_version.number,
30
+ )
31
+ )
31
32
 
32
33
  with python_models.PythonPublication.create(repository_version, pass_through=True) as pub:
33
34
  write_simple_api(pub)
34
35
 
35
- log.info(_('Publication: {pk} created').format(pk=pub.pk))
36
+ log.info(_("Publication: {pk} created").format(pk=pub.pk))
36
37
  return pub
37
38
 
38
39
 
@@ -49,26 +50,24 @@ def write_simple_api(publication):
49
50
  publication (pulpcore.plugin.models.Publication): A publication to generate metadata for
50
51
 
51
52
  """
52
- simple_dir = 'simple/'
53
+ simple_dir = "simple/"
53
54
  os.mkdir(simple_dir)
54
55
  project_names = (
55
56
  python_models.PythonPackageContent.objects.filter(
56
57
  pk__in=publication.repository_version.content
57
58
  )
58
- .order_by('name')
59
- .values_list('name', flat=True)
59
+ .order_by("name")
60
+ .values_list("name", flat=True)
60
61
  .distinct()
61
62
  )
62
63
 
63
64
  # write the root index, which lists all of the projects for which there is a package available
64
- index_path = '{simple_dir}index.html'.format(simple_dir=simple_dir)
65
- with open(index_path, 'w') as index:
65
+ index_path = "{simple_dir}index.html".format(simple_dir=simple_dir)
66
+ with open(index_path, "w") as index:
66
67
  index.write(write_simple_index(project_names))
67
68
 
68
69
  index_metadata = models.PublishedMetadata.create_from_file(
69
- relative_path=index_path,
70
- publication=publication,
71
- file=File(open(index_path, 'rb'))
70
+ relative_path=index_path, publication=publication, file=File(open(index_path, "rb"))
72
71
  )
73
72
  index_metadata.save()
74
73
 
@@ -84,41 +83,41 @@ def write_simple_api(publication):
84
83
  current_name = project_names[ind]
85
84
  package_releases = []
86
85
  for release in releases.iterator():
87
- if release['name'] != current_name:
86
+ if release["name"] != current_name:
88
87
  write_project_page(
89
88
  name=canonicalize_name(current_name),
90
89
  simple_dir=simple_dir,
91
90
  package_releases=package_releases,
92
- publication=publication
91
+ publication=publication,
93
92
  )
94
93
  package_releases = []
95
94
  ind += 1
96
95
  current_name = project_names[ind]
97
- relative_path = release['filename']
96
+ relative_path = release["filename"]
98
97
  path = f"../../{relative_path}"
99
- checksum = release['sha256']
98
+ checksum = release["sha256"]
100
99
  package_releases.append((relative_path, path, checksum))
101
100
  # Write the final project's page
102
101
  write_project_page(
103
102
  name=canonicalize_name(current_name),
104
103
  simple_dir=simple_dir,
105
104
  package_releases=package_releases,
106
- publication=publication
105
+ publication=publication,
107
106
  )
108
107
 
109
108
 
110
109
  def write_project_page(name, simple_dir, package_releases, publication):
111
110
  """Writes a project's simple page."""
112
- project_dir = f'{simple_dir}{name}/'
111
+ project_dir = f"{simple_dir}{name}/"
113
112
  os.mkdir(project_dir)
114
- metadata_relative_path = f'{project_dir}index.html'
113
+ metadata_relative_path = f"{project_dir}index.html"
115
114
 
116
- with open(metadata_relative_path, 'w') as simple_metadata:
115
+ with open(metadata_relative_path, "w") as simple_metadata:
117
116
  simple_metadata.write(write_simple_detail(name, package_releases))
118
117
 
119
118
  project_metadata = models.PublishedMetadata.create_from_file(
120
119
  relative_path=metadata_relative_path,
121
120
  publication=publication,
122
- file=File(open(metadata_relative_path, 'rb'))
121
+ file=File(open(metadata_relative_path, "rb")),
123
122
  )
124
123
  project_metadata.save() # change to bulk create when multi-table supported