Skip to content

Commit cbb9320

Browse files
committed
Add support for ATRIS
1 parent 205dc1c commit cbb9320

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

src/find_datalad_repos/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ def set_mode(
2828
default=logging.INFO,
2929
help="Set logging level [default: INFO]",
3030
)
31+
@click.option(
32+
"--atris",
33+
flag_value=RepoHost.ATRIS,
34+
type=click.UNPROCESSED,
35+
callback=set_mode,
36+
expose_value=False,
37+
help="Update ATRIS data",
38+
)
3139
@click.option(
3240
"--gin",
3341
flag_value=RepoHost.GIN,
@@ -96,6 +104,8 @@ def main(log_level: int, regen_readme: bool, mode: set[RepoHost] | None = None)
96104
reports.extend(
97105
record.update_hub_datalad_org(os.environ["HUB_DATALAD_ORG_TOKEN"])
98106
)
107+
if RepoHost.ATRIS in mode:
108+
reports.extend(record.update_atris())
99109
with open(RECORD_FILE, "w") as fp:
100110
print(record.model_dump_json(indent=4), file=fp)
101111

src/find_datalad_repos/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class RepoHost(Enum):
1818
GIN = 2
1919
OSF = 3
2020
HUB_DATALAD_ORG = 4
21+
ATRIS = 5
2122

2223

2324
class Updater(ABC, Generic[T, U, S]):

src/find_datalad_repos/diff.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def main(
6363
old_osf_repos = {r.id for r in from_record.osf}
6464
old_gin_repos = {r.id for r in from_record.gin}
6565
old_hub_repos = {r.id for r in from_record.hub_datalad_org}
66+
old_atris_repos = {r.id for r in from_record.atris}
6667
new_record = RepoRecord()
6768
for ghr in to_record.github:
6869
if ghr.name not in old_github_repos:
@@ -76,6 +77,9 @@ def main(
7677
for hubr in to_record.hub_datalad_org:
7778
if hubr.id not in old_hub_repos:
7879
new_record.hub_datalad_org.append(hubr)
80+
for atrisr in to_record.atris:
81+
if atrisr.id not in old_atris_repos:
82+
new_record.atris.append(atrisr)
7983
mkreadmes(new_record, filename=readme_file, directory=readme_dir)
8084

8185

src/find_datalad_repos/gin.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,20 @@ def as_table_row(self) -> TableRow:
5555

5656

5757
class GINSearcher(Client, Searcher[GINRepo]):
58-
def __init__(self, token: str, url: str | None = None) -> None:
58+
def __init__(self, token: str | None = None, url: str | None = None) -> None:
5959
if url is None:
6060
url = "https://gin.g-node.org"
61+
headers = {}
62+
if token is not None:
63+
# Passing `token` directly to ghreq results in an Authorization
64+
# header of "Bearer {token}", which GIN doesn't seem to support.
65+
headers["Authorization"] = f"token {token}"
6166
super().__init__(
6267
api_url=f"{url}/api/v1",
6368
user_agent=USER_AGENT,
6469
accept=None,
6570
api_version=None,
66-
# Passing `token` directly to ghreq results in an Authorization
67-
# header of "Bearer {token}", which GIN doesn't seem to support.
68-
headers={"Authorization": f"token {token}"},
71+
headers=headers,
6972
# Don't retry on 500's until
7073
# <https://github.com/G-Node/gogs/issues/148> is resolved
7174
retry_config=RetryConfig(retry_statuses=range(501, 600)),

src/find_datalad_repos/readmes.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def mkreadmes(
3737
base_url="https://hub.datalad.org",
3838
header="hub.datalad.org",
3939
)
40+
(atris_block, atris_active, atris_gone) = make_gin_tables(
41+
record.atris,
42+
Path(directory, "atris"),
43+
base_url="https://atris.fz-juelich.de",
44+
header="ATRIS",
45+
)
4046
(osf_block, osf_active, osf_gone) = make_osf_tables(record.osf)
4147
with open(filename, "w") as fp:
4248
print("# Summary", file=fp)
@@ -62,11 +68,17 @@ def mkreadmes(
6268
f" [{hub_gone}](#gone-3) gone",
6369
file=fp,
6470
)
71+
print(
72+
f"- [ATRIS](#atris): [{atris_active}](#active-3) active +"
73+
f" [{atris_gone}](#gone-4) gone",
74+
file=fp,
75+
)
6576
print(file=fp)
6677
print(github_block, file=fp)
6778
print(osf_block, file=fp)
6879
print(gin_block, file=fp)
69-
print(hub_block, end="", file=fp)
80+
print(hub_block, file=fp)
81+
print(atris_block, end="", file=fp)
7082

7183

7284
def make_github_tables(

src/find_datalad_repos/record.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class RepoRecord(BaseModel):
1212
osf: list[OSFRepo] = Field(default_factory=list)
1313
gin: list[GINRepo] = Field(default_factory=list)
1414
hub_datalad_org: list[GINRepo] = Field(default_factory=list)
15+
atris: list[GINRepo] = Field(default_factory=list)
1516

1617
def update_github(self, token: str) -> list[str]:
1718
return update_collection(self.github, GitHubUpdater, token=token)
@@ -27,6 +28,11 @@ def update_hub_datalad_org(self, token: str) -> list[str]:
2728
self.hub_datalad_org, GINUpdater, token=token, url="https://hub.datalad.org"
2829
)
2930

31+
def update_atris(self) -> list[str]:
32+
return update_collection(
33+
self.atris, GINUpdater, url="https://atris.fz-juelich.de"
34+
)
35+
3036

3137
def update_collection(
3238
collection: list[T], updater_cls: type[Updater[T, U, S]], **searcher_kwargs: Any

0 commit comments

Comments
 (0)