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