Verified Commit 9fa1d0e0 authored by David Runge's avatar David Runge
Browse files

Add documentation to all models

repo_management/models.py:
Document all models and sort the single attribute models alphabetically
for easier readibility.
Change the `License` model to describe a required attribute instead of
an optional (all packages need a license).
Remove the unused model `PackageFiles`.
parent 3c443e22
...@@ -6,194 +6,353 @@ from pydantic import BaseModel ...@@ -6,194 +6,353 @@ from pydantic import BaseModel
from repo_management import defaults from repo_management import defaults
class Arch(BaseModel):
"""A model describing a single 'arch' attribute
Attributes
----------
arch: str
The attribute can be used to describe the (required) data below an %ARCH% identifier in a 'desc' file, which
identifies a package's architecture
"""
arch: str
class Backup(BaseModel):
"""A model describing a single 'backup' attribute
Attributes
----------
backup: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %BACKUP% identifier in a 'desc' file, which
identifies which file(s) of a package pacman will create backups for
"""
backup: Optional[List[str]]
class Base(BaseModel): class Base(BaseModel):
"""A model describing the %BASE% header in a 'desc' file, which type it represents and whether it is required or """A model describing a single 'base' attribute
not"""
Attributes
----------
base: str base: str
The attribute can be used to describe the (required) data below a %BASE% identifier in a 'desc' file, which
identifies a package's pkgbase
"""
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 BuildDate(BaseModel):
"""A model describing a single 'builddate' attribute
class MakeDepends(BaseModel): Attributes
"""A model describing the %MAKEDEPENDS% header in a 'desc' file, which type it represents and whether it is required ----------
or not""" builddate: int
The attribute can be used to describe the (required) data below a %BUILDDATE% identifier in a 'desc' file,
which identifies a package's build date (represented in seconds since the epoch)
"""
makedepends: Optional[List[str]] builddate: int
class CheckDepends(BaseModel): class CheckDepends(BaseModel):
"""A model describing the %CHECKDEPENDS% header in a 'desc' file, which type it represents and whether it is """A model describing a single 'checkdepends' attribute
required or not"""
Attributes
----------
checkdepends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %CHECKDEPENDS% identifier in a 'desc' file,
which identifies a package's checkdepends
"""
checkdepends: Optional[List[str]] checkdepends: Optional[List[str]]
class FileName(BaseModel): class Conflicts(BaseModel):
"""A model describing the %FILENAME% header in a 'desc' file, which type it represents and whether it is required or """A model describing a single 'conflicts' attribute
not"""
filename: str Attributes
----------
conflicts: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %CONFLICTS% identifier in a 'desc' file, which
identifies what other package(s) a package conflicts with
"""
conflicts: Optional[List[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 CSize(BaseModel):
"""A model describing a single 'csize' attribute
Attributes
----------
csize: int
The attribute can be used to describe the (required) data below a %CSIZE% identifier in a 'desc' file, which
identifies a package's size
"""
csize: int
class Depends(BaseModel):
"""A model describing a single 'depends' attribute
Attributes
----------
depends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %DEPENDS% identifier in a 'desc' file, which
identifies what other package(s) a package depends on
"""
depends: Optional[List[str]]
class Desc(BaseModel): class Desc(BaseModel):
"""A model describing the %DESC% header in a 'desc' file, which type it represents and whether it is required or """A model describing a single 'desc' attribute
not"""
Attributes
----------
desc: str desc: str
The attribute can be used to describe the (required) data below a %DESC% identifier in a 'desc' file, which
identifies a package's description
"""
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 FileName(BaseModel):
"""A model describing a single 'filename' attribute
Attributes
----------
filename: str
The attribute can be used to describe the (required) data below a %FILENAME% identifier in a 'desc' file, which
identifies a package's file name
"""
class CSize(BaseModel): filename: str
"""A model describing the %CSIZE% header in a 'desc' file, which type it represents and whether it is required or
not"""
csize: int
class Files(BaseModel):
"""A model describing a single 'files' attribute
class ISize(BaseModel): Attributes
"""A model describing the %ISIZE% header in a 'desc' file, which type it represents and whether it is required or ----------
not""" files: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %FILES% identifier in a 'files' file, which
identifies which file(s) belong to a package
"""
isize: int files: Optional[List[str]]
class Md5Sum(BaseModel): class Groups(BaseModel):
"""A model describing the %MD5SUM% header in a 'desc' file, which type it represents and whether it is required or """A model describing a single 'groups' attribute
not"""
md5sum: str Attributes
----------
groups: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %GROUPS% identifier in a 'desc' file, which
identifies a package's groups
"""
groups: Optional[List[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 ISize(BaseModel):
"""A model describing a single 'isize' attribute
Attributes
----------
isize: int
The attribute can be used to describe the (required) data below an %ISIZE% identifier in a 'desc' file, which
identifies a package's size
"""
class PgpSig(BaseModel): isize: int
"""A model describing the %PGPSIG% header in a 'desc' file, which type it represents and whether it is required or
not"""
pgpsig: str
class License(BaseModel):
"""A model describing a single 'license' attribute
class Url(BaseModel): Attributes
"""A model describing the %URL% header in a 'desc' file, which type it represents and whether it is required or ----------
not""" license: List[str]
The attribute can be used to describe the (required) data below a %LICENSE% identifier in a 'desc' file, which
identifies a package's license(s)
"""
url: str license: List[str]
class License(BaseModel): class MakeDepends(BaseModel):
"""A model describing the %LICENSE% header in a 'desc' file, which type it represents and whether it is required or """A model describing a single 'makedepends' attribute
not"""
license: Optional[List[str]] Attributes
----------
makedepends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %MAKEDEPENDS% identifier in a 'desc' file,
which identifies a package's makedepends
"""
makedepends: Optional[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 Md5Sum(BaseModel):
"""A model describing a single 'md5sum' attribute
Attributes
----------
md5sum: str
The attribute can be used to describe the (required) data below an %MD5SUM% identifier in a 'desc' file, which
identifies a package's md5 checksum
"""
class BuildDate(BaseModel): md5sum: str
"""A model describing the %BUILDDATE% header in a 'desc' file, which type it represents and whether it is required
or not"""
builddate: int
class Name(BaseModel):
"""A model describing a single 'name' attribute
Attributes
----------
name: str
The attribute can be used to describe the (required) data below a %NAME% identifier in a 'desc' file, which
identifies a package's name
"""
name: str
class Packager(BaseModel): class Packager(BaseModel):
"""A model describing the %PACKAGER% header in a 'desc' file, which type it represents and whether it is required """A model describing a single 'packager' attribute
or not"""
Attributes
----------
packager: str
The attribute can be used to describe the (required) data below a %PACKAGER% identifier in a 'desc' file, which
identifies a package's packager
"""
packager: str packager: str
class PgpSig(BaseModel):
"""A model describing a single 'pgpsig' attribute
Attributes
----------
pgpsig: str
The attribute can be used to describe the (required) data below a %PGPSIG% identifier in a 'desc' file, which
identifies a package's PGP signature
"""
pgpsig: str
class Provides(BaseModel):
"""A model describing a single 'provides' attribute
Attributes
----------
provides: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %PROVIDES% identifier in a 'desc' file, which
identifies what other package(s) a package provides
"""
provides: Optional[List[str]]
class Replaces(BaseModel): class Replaces(BaseModel):
"""A model describing the %REPLACES% header in a 'desc' file, which type it represents and whether it is required or """A model describing a single 'replaces' attribute
not"""
Attributes
----------
replaces: Optional[List[str]] replaces: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %REPLACES% identifier in a 'desc' file, which
identifies what other package(s) a package replaces
"""
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 RepoDbMemberType(BaseModel):
"""A model describing a single 'member_type' attribute, which is used to identify/ distinguish different types of
repository database file types (e.g. 'desc' and 'files' files, which are contained in a repository database file).
Attributes
----------
member_type: defaults.RepoDbMemberType
A member of the IntEnum defaults.RepoDbMemberType
"""
class Provides(BaseModel): member_type: defaults.RepoDbMemberType
"""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 Sha256Sum(BaseModel):
"""A model describing a single 'sha256sum' attribute
class Depends(BaseModel): Attributes
"""A model describing the %DEPENDS% header in a 'desc' file, which type it represents and whether it is required or ----------
not""" sha256sum: str
The attribute can be used to describe the (required) data below an %SHA256SUM% identifier in a 'desc' file,
which identifies a package's sha256 checksum
"""
depends: Optional[List[str]] sha256sum: str
class OptDepends(BaseModel): class OptDepends(BaseModel):
"""A model describing the %OPTDEPENDS% header in a 'desc' file, which type it represents and whether it is required """A model describing a single 'optdepends' attribute
or not"""
Attributes
----------
optdepends: Optional[List[str]] optdepends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %OPTDEPENDS% identifier in a 'desc' file,
which identifies what other package(s) a package optionally depends on
"""
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 Url(BaseModel):
"""A model describing a single 'url' attribute
Attributes
----------
url: str
The attribute can be used to describe the (required) data below a %URL% identifier in a 'desc' file, which
identifies a package's URL
"""
class Files(BaseModel): url: str
"""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]]
class Version(BaseModel):
"""A model describing a single 'version' attribute
class PackageFiles(Name, Files): Attributes
pass ----------
version: str
The attribute can be used to describe the (required) data below a %VERSION% identifier in a 'desc' file, which
identifies a package's version (this is the accumulation of epoch, pkgver and pkgrel)
"""
version: str
class OutputPackage( class OutputPackage(
Arch, Arch,
Backup, Backup,
BuildDate, BuildDate,
CheckDepends,
Conflicts, Conflicts,
CSize, CSize,
Depends, Depends,
Desc, Desc,
CheckDepends,
FileName, FileName,
Files, Files,
Groups, Groups,
...@@ -208,8 +367,73 @@ class OutputPackage( ...@@ -208,8 +367,73 @@ class OutputPackage(
Sha256Sum, Sha256Sum,
Url, Url,
): ):
"""A model describing all required attributes for a package in the context of an output file, that describes a """A model describing all required attributes that define a package in the context of an output file
(potential) list of packages based upon its pkgbase
Attributes
----------
arch: str
The attribute can be used to describe the (required) data below an %ARCH% identifier in a 'desc' file, which
identifies a package's architecture
backup: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %BACKUP% identifier in a 'desc' file, which
identifies which file(s) of a package pacman will create backups for
builddate: int
The attribute can be used to describe the (required) data below a %BUILDDATE% identifier in a 'desc' file,
which identifies a package's build date (represented in seconds since the epoch)
checkdepends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %CHECKDEPENDS% identifier in a 'desc' file,
which identifies a package's checkdepends
conflicts: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %CONFLICTS% identifier in a 'desc' file, which
identifies what other package(s) a package conflicts with
csize: int
The attribute can be used to describe the (required) data below a %CSIZE% identifier in a 'desc' file, which
identifies a package's size
depends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %DEPENDS% identifier in a 'desc' file, which
identifies what other package(s) a package depends on
desc: str
The attribute can be used to describe the (required) data below a %DESC% identifier in a 'desc' file, which
identifies a package's description
filename: str
The attribute can be used to describe the (required) data below a %FILENAME% identifier in a 'desc' file, which
identifies a package's file name
files: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %FILES% identifier in a 'files' file, which
identifies which file(s) belong to a package
groups: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %GROUPS% identifier in a 'desc' file, which
identifies a package's groups
isize: int
The attribute can be used to describe the (required) data below an %ISIZE% identifier in a 'desc' file, which
identifies a package's size
license: List[str]
The attribute can be used to describe the (required) data below a %LICENSE% identifier in a 'desc' file, which
identifies a package's license(s)
md5sum: str
The attribute can be used to describe the (required) data below an %MD5SUM% identifier in a 'desc' file, which
identifies a package's md5 checksum
name: str
The attribute can be used to describe the (required) data below a %NAME% identifier in a 'desc' file, which
identifies a package's name
optdepends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %OPTDEPENDS% identifier in a 'desc' file,
which identifies what other package(s) a package optionally depends on
pgpsig: str
The attribute can be used to describe the (required) data below a %PGPSIG% identifier in a 'desc' file, which
identifies a package's PGP signature
provides: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %PROVIDES% identifier in a 'desc' file, which
identifies what other package(s) a package provides
replaces: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %REPLACES% identifier in a 'desc' file, which
identifies what other package(s) a package replaces
sha256sum: str
The attribute can be used to describe the (required) data below an %SHA256SUM% identifier in a 'desc' file,
which identifies a package's sha256 checksum
url: str
The attribute can be used to describe the (required) data below a %URL% identifier in a 'desc' file, which
identifies a package's URL
""" """
pass pass
...@@ -220,11 +444,11 @@ class PackageDesc( ...@@ -220,11 +444,11 @@ class PackageDesc(
Backup, Backup,
Base, Base,
BuildDate, BuildDate,
CheckDepends,
Conflicts, Conflicts,
CSize, CSize,
Depends, Depends,
Desc, Desc,
CheckDepends,
FileName, FileName,
Groups, Groups,
ISize, ISize,
...@@ -241,8 +465,83 @@ class PackageDesc( ...@@ -241,8 +465,83 @@ class PackageDesc(
Url, Url,
Version, Version,
): ):
"""A model describing all headers in a 'desc' file, which type they represent and whether they are required or """A model describing all identifiers in a 'desc' file
not"""
Attributes
----------
arch: str
The attribute can be used to describe the (required) data below an %ARCH% identifier in a 'desc' file, which
identifies a package's architecture
backup: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %BACKUP% identifier in a 'desc' file, which
identifies which file(s) of a package pacman will create backups for
base: str
The attribute can be used to describe the (required) data below a %BASE% identifier in a 'desc' file, which
identifies a package's pkgbase
builddate: int
The attribute can be used to describe the (required) data below a %BUILDDATE% identifier in a 'desc' file,
which identifies a package's build date (represented in seconds since the epoch)
checkdepends: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %CHECKDEPENDS% identifier in a 'desc' file,
which identifies a package's checkdepends
conflicts: Optional[List[str]]
The attribute can be used to describe the (optional) data below a %CONFLICTS% identifier in a 'desc' file, which
identifies what other package(s) a package conflicts with
csize: int