43 lines
1 KiB
Python
43 lines
1 KiB
Python
"""Continuous Integration projects."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from spcd.util import add_url_path
|
|
|
|
GROUP_AND_NAME = [
|
|
"GITHUB_REPOSITORY",
|
|
"CI_PROJECT_PATH",
|
|
]
|
|
SERVER_URL = [
|
|
"GITHUB_SERVER_URL",
|
|
"CI_SERVER_URL",
|
|
]
|
|
|
|
|
|
class Projects:
|
|
"""Other projects."""
|
|
|
|
def __init__(self: Projects) -> None:
|
|
"""Set environment, group, name & url."""
|
|
self.environment = os.environ
|
|
# group, name
|
|
for variable in GROUP_AND_NAME:
|
|
if value := self.environment.get(variable, None):
|
|
path = Path(value)
|
|
self.group = str(path.parent)
|
|
self.name = path.name
|
|
# url
|
|
for variable in SERVER_URL:
|
|
if value := self.environment.get(variable, None):
|
|
self.url = add_url_path(value, self.group)
|
|
|
|
def __str__(self: Projects) -> str:
|
|
"""List group, name & url."""
|
|
return f"""\
|
|
group = {self.group}
|
|
name = {self.name}
|
|
url = {self.url}
|
|
"""
|