forked from fedora-copr/copr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: use common enum constants for sharing descriptions
... between fields and forms
- Loading branch information
Showing
8 changed files
with
93 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,56 @@ | ||
""" | ||
File which contains only constants. Nothing else. | ||
""" | ||
|
||
from collections import namedtuple | ||
from enum import Enum | ||
from typing import Any | ||
|
||
BANNER_LOCATION = "/var/lib/copr/data/banner-include.html" | ||
|
||
DEFAULT_COPR_REPO_PRIORITY = 99 | ||
|
||
|
||
CommonAttribute = namedtuple( | ||
"CommonAttribute", ["description", "default"], defaults=("", None) | ||
) | ||
|
||
|
||
# just shortcut | ||
c = CommonAttribute # pylint: disable=invalid-name | ||
|
||
|
||
# Common descriptions for forms, fields, etc. | ||
class CommonDescriptions(Enum): | ||
""" | ||
Enumerator for common descriptions and their default value between forms, | ||
fields, etc. | ||
""" | ||
ADDITIONAL_PACKAGES = c( | ||
"Additional packages to be always present in minimal buildroot" | ||
) | ||
MOCK_CHROOT = c("Mock chroot", "fedora-latest-x86_64") | ||
ADDITIONAL_REPOS = c("Additional repos to be used for builds in this chroot") | ||
ENABLE_NET = c("Enable internet access during builds") | ||
PYPI_PACKAGE_NAME = c("Package name in the Python Package Index") | ||
PYPI_PACKAGE_VERSION = c("PyPI package version") | ||
SPEC_GENERATOR = c( | ||
"Tool for generating specfile from a PyPI package. " | ||
"The options are full-featured pyp2rpm with cross " | ||
"distribution support, and pyp2spec that is being actively " | ||
"developed and considered to be the future." | ||
) | ||
AUTO_REBUILD = c("Auto-rebuild the package? (i.e. every commit or new tag)") | ||
|
||
@property | ||
def description(self) -> str: | ||
""" | ||
Get description of Enum member | ||
""" | ||
return self.value.description | ||
|
||
@property | ||
def default(self) -> Any: | ||
""" | ||
Fet default value of Enum member | ||
""" | ||
return self.value.default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters