2
2
3
3
from django .db import models
4
4
5
- from pulpcore .plugin .models import Content , Remote , Model , Publisher
5
+ from pulpcore .plugin .models import Content , Model , Publisher , Remote
6
6
7
7
log = getLogger (__name__ )
8
8
9
9
10
- PACKAGE_TYPES = (("bdist_dmg" , "bdist_dmg" ), ("bdist_dumb" , "bdist_dumb" ),
11
- ("bdist_egg" , "bdist_egg" ), ("bdist_msi" , "bdist_msi" ),
12
- ("bdist_rpm" , "bdist_rpm" ), ("bdist_wheel" , "bdist_wheel" ),
13
- ("bdist_wininst" , "bdist_wininst" ), ("sdist" , "sdist" ))
10
+ PACKAGE_TYPES = (
11
+ ("bdist_dmg" , "bdist_dmg" ),
12
+ ("bdist_dumb" , "bdist_dumb" ),
13
+ ("bdist_egg" , "bdist_egg" ),
14
+ ("bdist_msi" , "bdist_msi" ),
15
+ ("bdist_rpm" , "bdist_rpm" ),
16
+ ("bdist_wheel" , "bdist_wheel" ),
17
+ ("bdist_wininst" , "bdist_wininst" ),
18
+ ("sdist" , "sdist" ),
19
+ )
14
20
15
21
16
22
class Classifier (Model ):
17
23
"""
18
- Custom tags for classifier
24
+ Custom tags for classifier.
19
25
20
26
Fields:
21
27
@@ -25,25 +31,30 @@ class Classifier(Model):
25
31
26
32
python_package_content (models.ForeignKey): The PythonPackageContent this classifier
27
33
is associated with.
28
-
29
34
"""
30
35
31
36
name = models .TextField ()
32
- python_package_content = models .ForeignKey ("PythonPackageContent" , related_name = "classifiers" ,
33
- related_query_name = "classifier" ,
34
- on_delete = models .CASCADE )
37
+ python_package_content = models .ForeignKey (
38
+ "PythonPackageContent" ,
39
+ related_name = "classifiers" ,
40
+ related_query_name = "classifier" ,
41
+ on_delete = models .CASCADE
42
+ )
35
43
36
44
37
45
class DistributionDigest (Model ):
38
46
"""
39
47
A model of digests on an individual distribution.
40
48
"""
49
+
41
50
type = models .TextField ()
42
51
digest = models .TextField ()
43
- project_specifier = models .ForeignKey ("ProjectSpecifier" ,
44
- related_name = "digests" ,
45
- related_query_name = "distributiondigest" ,
46
- on_delete = models .CASCADE )
52
+ project_specifier = models .ForeignKey (
53
+ "ProjectSpecifier" ,
54
+ related_name = "digests" ,
55
+ related_query_name = "distributiondigest" ,
56
+ on_delete = models .CASCADE
57
+ )
47
58
48
59
49
60
class ProjectSpecifier (Model ):
@@ -69,16 +80,20 @@ class ProjectSpecifier(Model):
69
80
70
81
name = models .TextField ()
71
82
version_specifier = models .TextField (blank = True , default = "" )
72
- remote = models .ForeignKey ("PythonRemote" ,
73
- related_name = "projects" ,
74
- related_query_name = "projectspecifier" ,
75
- on_delete = models .CASCADE )
83
+ remote = models .ForeignKey (
84
+ "PythonRemote" ,
85
+ related_name = "projects" ,
86
+ related_query_name = "projectspecifier" ,
87
+ on_delete = models .CASCADE
88
+ )
76
89
77
90
78
91
class PythonPackageContent (Content ):
79
92
"""
80
- A Content Type representing Python's Distribution Package as
81
- defined in pep-0426 and pep-0345
93
+ A Content Type representing Python's Distribution Package.
94
+
95
+ As defined in pep-0426 and pep-0345.
96
+
82
97
https://www.python.org/dev/peps/pep-0491/
83
98
https://www.python.org/dev/peps/pep-0345/
84
99
"""
@@ -112,20 +127,30 @@ class PythonPackageContent(Content):
112
127
113
128
@property
114
129
def artifact (self ):
130
+ """
131
+ Return the artifact id (there is only one for this content type).
132
+ """
115
133
return self .artifacts .get ().pk
116
134
117
135
class Meta :
118
- unique_together = (
119
- 'filename' ,
120
- )
136
+ unique_together = ('filename' ,)
121
137
122
138
def __str__ (self ):
123
139
"""
124
- Overrides Content.str to provide the distribution version and type at the end.
140
+ Provide more useful repr information.
141
+
142
+ Overrides Content.str to provide the distribution version and type at
143
+ the end.
144
+
125
145
e.g. <PythonPackageContent: shelf-reader [version] (whl)>
146
+
126
147
"""
127
- return '<{}: {} [{}] ({})>' .format (
128
- self ._meta .object_name , self .name , self .version , self .packagetype )
148
+ return '<{obj_name}: {name} [{version}] ({type})>' .format (
149
+ obj_name = self ._meta .object_name ,
150
+ name = self .name ,
151
+ version = self .version ,
152
+ type = self .packagetype
153
+ )
129
154
130
155
131
156
class PythonPublisher (Publisher ):
@@ -139,9 +164,6 @@ class PythonPublisher(Publisher):
139
164
class PythonRemote (Remote ):
140
165
"""
141
166
A Remote for Python Content.
142
-
143
- Attributes:
144
- projects (list): A list of python projects to sync
145
167
"""
146
168
147
169
TYPE = 'python'
0 commit comments