aboutsummaryrefslogtreecommitdiff
path: root/repos/base.py
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-12 12:12:16 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-12 12:12:16 -0600
commit7591c0f54fa3272df0f6b7057f6096bb513e9328 (patch)
tree96ee729a98ca2904da9779f4ccf7659aa3e8a038 /repos/base.py
parent52737fe6fdec0d168a3f31a632a9cfb3f91a9e4f (diff)
downloadwhere-packaged-7591c0f54fa3272df0f6b7057f6096bb513e9328.tar.gz
where-packaged-7591c0f54fa3272df0f6b7057f6096bb513e9328.zip
give sections a separate thingHEADcanon
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