diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-29 18:55:00 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-29 18:55:00 -0600 |
commit | 2a45e45fd09f659253b44f35550de056e8e39a59 (patch) | |
tree | f90728c7c9e7620348df9a3d297a2f5684274753 /repos | |
parent | 563eda8e7772a49ebe242b65849359db0a077672 (diff) | |
download | where-packaged-2a45e45fd09f659253b44f35550de056e8e39a59.tar.gz where-packaged-2a45e45fd09f659253b44f35550de056e8e39a59.zip |
allow repositories with no family
Diffstat (limited to 'repos')
-rw-r--r-- | repos/base.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/repos/base.py b/repos/base.py index c7790c1..3537f05 100644 --- a/repos/base.py +++ b/repos/base.py @@ -4,7 +4,7 @@ import gzip import json from pathlib import Path import re -from typing import Any, Callable, Mapping +from typing import Any, Callable, Mapping, Optional import requests import semver @@ -55,16 +55,22 @@ class JSONDecoder(json.JSONDecoder): @dataclass() class Repository: - family: str + family: Optional[str] repo: str index_url: str parse: Callable[[Path], Mapping[str, Version]] def full_name(self): - return f'{self.family} {self.repo}' + if self.family is None: + return self.repo + else: + return f'{self.family} {self.repo}' def _cache_dir(self) -> Path: - return Path('data') / slug(self.family) / slug(self.repo) + if self.family is None: + return Path('data') / slug(self.repo) + else: + return Path('data') / slug(self.family) / slug(self.repo) def _cache_file(self, name: str) -> Path: return self._cache_dir() / name |