aboutsummaryrefslogtreecommitdiff
path: root/repos/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'repos/base.py')
-rw-r--r--repos/base.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/repos/base.py b/repos/base.py
index 1b4c42b..de0e5dc 100644
--- a/repos/base.py
+++ b/repos/base.py
@@ -58,24 +58,38 @@ class JSONDecoder(json.JSONDecoder):
super().__init__(object_hook=self.object_hook)
-@dataclass()
+@dataclass(frozen=True)
class Repository:
family: Optional[str]
repo: str
+ section: Optional[str]
index_url: str
parse: Callable[[Path], Mapping[str, Version]]
def full_name(self):
- if self.family is None:
- return self.repo
- else:
- return f'{self.family} {self.repo}'
+ prefix = ''
+ if self.family is not None:
+ prefix = self.family + ' '
+ suffix = ''
+ if self.section is not None:
+ suffix = ' ' + self.section
+ return f'{prefix}{self.repo}{suffix}'
+
+ @property
+ def full_repo_name(self):
+ prefix = ''
+ if self.family is not None:
+ prefix = self.family + ' '
+ return f'{prefix}{self.repo}'
def _cache_dir(self) -> Path:
- if self.family is None:
- return Path('data') / slug(self.repo)
- else:
- return Path('data') / slug(self.family) / slug(self.repo)
+ result = Path('data')
+ if self.family is not None:
+ result = result / slug(self.family)
+ result = result / slug(self.repo)
+ if self.section is not None:
+ result = result / slug(self.section)
+ return result
def _cache_file(self, name: str) -> Path:
return self._cache_dir() / name