models.py 6.3 KB
Newer Older
1
import io
2
3
4
5
from typing import List, Optional

from pydantic import BaseModel

6
7
from repo_management import defaults

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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

class Base(BaseModel):
    """A model describing the %BASE% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    base: str


class Version(BaseModel):
    """A model describing the %VERSION% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    version: str


class MakeDepends(BaseModel):
    """A model describing the %MAKEDEPENDS% header in a 'desc' file, which type it represents and whether it is required
    or not"""

    makedepends: Optional[List[str]]


class CheckDepends(BaseModel):
    """A model describing the %CHECKDEPENDS% header in a 'desc' file, which type it represents and whether it is
    required or not"""

    checkdepends: Optional[List[str]]


class FileName(BaseModel):
    """A model describing the %FILENAME% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    filename: str


class Name(BaseModel):
    """A model describing the %NAME% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    name: str


class Desc(BaseModel):
    """A model describing the %DESC% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    desc: str


class Groups(BaseModel):
    """A model describing the %GROUPS% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    groups: Optional[List[str]]


class CSize(BaseModel):
    """A model describing the %CSIZE% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    csize: int


class ISize(BaseModel):
    """A model describing the %ISIZE% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    isize: int


class Md5Sum(BaseModel):
    """A model describing the %MD5SUM% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    md5sum: str


class Sha256Sum(BaseModel):
    """A model describing the %SHA256SUM% header in a 'desc' file, which type it represents and whether it is required
    or not"""

    sha256sum: str


class PgpSig(BaseModel):
    """A model describing the %PGPSIG% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    pgpsig: str


class Url(BaseModel):
    """A model describing the %URL% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    url: str


class License(BaseModel):
    """A model describing the %LICENSE% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    licenses: List[str]


class Arch(BaseModel):
    """A model describing the %ARCH% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    arch: str


class BuildDate(BaseModel):
    """A model describing the %BUILDDATE% header in a 'desc' file, which type it represents and whether it is required
    or not"""

    builddate: int


class Packager(BaseModel):
    """A model describing the %PACKAGER% header in a 'desc' file, which type it represents and whether it is required
    or not"""

    packager: str


class Replaces(BaseModel):
    """A model describing the %REPLACES% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    replaces: Optional[List[str]]


class Conflicts(BaseModel):
    """A model describing the %CONFLICTS% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    conflicts: Optional[List[str]]


class Provides(BaseModel):
    """A model describing the %PROVIDES% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    provides: Optional[List[str]]


class Depends(BaseModel):
    """A model describing the %DEPENDS% header in a 'desc' file, which type it represents and whether it is required or
    not"""

    depends: Optional[List[str]]


class OptDepends(BaseModel):
    """A model describing the %OPTDEPENDS% header in a 'desc' file, which type it represents and whether it is required
    or not"""

    optdepends: Optional[List[str]]


class Backup(BaseModel):
    """A model describing the %BACKUP% header in a 'desc' file, which type it represents and whether it is required
    or not"""

    backup: Optional[List[str]]


class Files(BaseModel):
    """A model describing the %FILES% header in a 'files' file, which type it represents and whether it is required or
    not"""

    files: Optional[List[str]]


184
185
186
187
class PackageFiles(Name, Files):
    pass


188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
class PackageDesc(
    Arch,
    Backup,
    Base,
    BuildDate,
    Conflicts,
    CSize,
    Depends,
    Desc,
    CheckDepends,
    FileName,
    Groups,
    ISize,
    License,
    MakeDepends,
    Md5Sum,
    Name,
    OptDepends,
    Packager,
    PgpSig,
    Provides,
    Replaces,
    Sha256Sum,
    Url,
    Version,
):
    """A model describing all headers in a 'desc' file, which type they represent and whether they are required or
    not"""

    pass
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275


class RepoDbMemberType(BaseModel):
    """A model describing an attribute used to identify/ distinguish different types of repo database file types (e.g.
    'desc' and 'files' files, which are contained in a repository database file).
    The file types are distinguished with the help of the IntEnum defaults.REpoDbFileType
    """

    member_type: defaults.RepoDbMemberType


class RepoDbMemberData(Name, RepoDbMemberType):
    data: io.StringIO

    class Config:
        arbitrary_types_allowed = True


class OutputPackage(
    Arch,
    Backup,
    BuildDate,
    Conflicts,
    CSize,
    Depends,
    Desc,
    CheckDepends,
    FileName,
    Files,
    Groups,
    ISize,
    License,
    Md5Sum,
    Name,
    OptDepends,
    PgpSig,
    Provides,
    Replaces,
    Sha256Sum,
    Url,
):
    """A model describing all required attributes for a package in the context of an output file, that describes a
    (potential) list of packages based upon its pkgbase
    """

    pass


class OutputPackageBase(
    MakeDepends,
    Packager,
    Version,
):
    """A model describing all required attributes for an output file, that describes a list of packages based upon a
    pkgbase
    """

    packages: List[OutputPackage]