forked from pulp/pulp_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
138 lines (105 loc) · 3.4 KB
/
Copy pathmodels.py
File metadata and controls
138 lines (105 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from logging import getLogger
from django.contrib.postgres.fields import JSONField
from django.db import models
from pulpcore.plugin.models import (
Content,
Publication,
PublicationDistribution,
Remote,
Repository
)
log = getLogger(__name__)
PACKAGE_TYPES = (
("bdist_dmg", "bdist_dmg"),
("bdist_dumb", "bdist_dumb"),
("bdist_egg", "bdist_egg"),
("bdist_msi", "bdist_msi"),
("bdist_rpm", "bdist_rpm"),
("bdist_wheel", "bdist_wheel"),
("bdist_wininst", "bdist_wininst"),
("sdist", "sdist"),
)
class PythonDistribution(PublicationDistribution):
"""
Distribution for 'Python' Content.
"""
TYPE = 'python'
class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
class PythonPackageContent(Content):
"""
A Content Type representing Python's Distribution Package.
As defined in pep-0426 and pep-0345.
https://www.python.org/dev/peps/pep-0491/
https://www.python.org/dev/peps/pep-0345/
"""
TYPE = 'python'
# Required metadata
filename = models.TextField(unique=True, db_index=True)
packagetype = models.TextField(choices=PACKAGE_TYPES)
name = models.TextField()
version = models.TextField()
# Optional metadata
metadata_version = models.TextField()
summary = models.TextField()
description = models.TextField()
keywords = models.TextField()
home_page = models.TextField()
download_url = models.TextField()
author = models.TextField()
author_email = models.TextField()
maintainer = models.TextField()
maintainer_email = models.TextField()
license = models.TextField()
requires_python = models.TextField()
project_url = models.TextField()
platform = models.TextField()
supported_platform = models.TextField()
requires_dist = JSONField(default=list)
provides_dist = JSONField(default=list)
obsoletes_dist = JSONField(default=list)
requires_external = JSONField(default=list)
classifiers = JSONField(default=list)
def __str__(self):
"""
Provide more useful repr information.
Overrides Content.str to provide the distribution version and type at
the end.
e.g. <PythonPackageContent: shelf-reader [version] (whl)>
"""
return '<{obj_name}: {name} [{version}] ({type})>'.format(
obj_name=self._meta.object_name,
name=self.name,
version=self.version,
type=self.packagetype
)
class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
unique_together = ('filename',)
class PythonRepository(Repository):
"""
Repository for "python" content.
"""
TYPE = "python"
CONTENT_TYPES = [PythonPackageContent]
class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
class PythonPublication(Publication):
"""
A Publication for PythonContent.
"""
TYPE = 'python'
class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
class PythonRemote(Remote):
"""
A Remote for Python Content.
Fields:
prereleases (models.BooleanField): Whether to sync pre-release versions of packages.
"""
TYPE = 'python'
prereleases = models.BooleanField(default=False)
includes = JSONField(default=list)
excludes = JSONField(default=list)
class Meta:
default_related_name = "%(app_label)s_%(model_name)s"