Skip to content

Commit

Permalink
Python >= 3.10
Browse files Browse the repository at this point in the history
match case
  • Loading branch information
scivision committed Feb 18, 2024
1 parent 8f9f576 commit 92efd8c
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9', '3.x']
python-version: [ '3.10', '3.x']

name: Python ${{ matrix.python-version }}
steps:
Expand Down
13 changes: 7 additions & 6 deletions Github/AddOrganizationMembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ def main():

fn = Path(p.fn).expanduser()

if fn.suffix in {".xls", ".xlsx"}:
users = pandas.read_excel(fn, usecols=p.col).squeeze().dropna()
elif fn.suffix == ".csv":
users = pandas.read_csv(fn, usecols=[p.col]).squeeze().dropna()
else:
raise ValueError(f"Unknown file type {fn}")
match fn.suffix:
case ".xls" | ".xlsx":
users = pandas.read_excel(fn, usecols=p.col).squeeze().dropna()
case ".csv":
users = pandas.read_csv(fn, usecols=[p.col]).squeeze().dropna()
case _:
raise ValueError(f"Unknown file type {fn}")

if not users.ndim == 1:
raise ValueError("need to have member names. Check that -col argument matches spreadsheet.")
Expand Down
26 changes: 14 additions & 12 deletions Github/AddRepoMembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ def main():

fn = Path(p.fn).expanduser()

if fn.suffix in (".xls", ".xlsx"):
teams = pandas.read_excel(fn, usecols=p.col).squeeze().dropna()
elif fn.suffix == ".csv":
teams = pandas.read_csv(fn, usecols=p.col).squeeze().dropna()
else:
raise ValueError(f"Unknown file type {fn}")
match fn.suffix:
case ".xls" | ".xlsx":
teams = pandas.read_excel(fn, usecols=p.col).squeeze().dropna()
case ".csv":
teams = pandas.read_csv(fn, usecols=p.col).squeeze().dropna()
case _:
raise ValueError(f"Unknown file type {fn}")

if not teams.ndim == 2:
raise ValueError(
Expand All @@ -55,12 +56,13 @@ def main():

def adder(teams: pandas.DataFrame, stem: str, private: bool, create: bool, op, sess):
for _, row in teams.iterrows():
if row.size == 3:
repo_name = f"{stem}{row[TEAMS]:02.0f}-{row[NAME]}"
elif row.size == 2:
repo_name = f"{stem}{row[TEAMS]}"
else:
raise ValueError("I expect team number OR team number and team name")
match row.size:
case 3:
repo_name = f"{stem}{row[TEAMS]:02.0f}-{row[NAME]}"
case 2:
repo_name = f"{stem}{row[TEAMS]}"
case _:
raise ValueError("I expect team number OR team number and team name")

login = row[USERNAME].strip()
try:
Expand Down
27 changes: 14 additions & 13 deletions Github/AddTeamMembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
https://developer.github.com/v3/repos/#oauth-scope-requirements
"""

from __future__ import annotations
import sys
import logging
import pandas
Expand All @@ -38,12 +37,13 @@ def main():

fn = Path(p.fn).expanduser()

if fn.suffix in (".xls", ".xlsx"):
teams = pandas.read_excel(fn, usecols=p.col).squeeze().dropna()
elif fn.suffix == ".csv":
teams = pandas.read_csv(fn, usecols=p.col).squeeze().dropna()
else:
raise ValueError(f"Unknown file type {fn}")
match fn.suffix:
case ".xls" | ".xlsx":
teams = pandas.read_excel(fn, usecols=p.col).squeeze().dropna()
case ".csv":
teams = pandas.read_csv(fn, usecols=p.col).squeeze().dropna()
case _:
raise ValueError(f"Unknown file type {fn}")

if not teams.ndim == 2:
raise ValueError(
Expand All @@ -63,12 +63,13 @@ def adder(teams: pandas.DataFrame, stem: str, create: bool, op, sess) -> list[tu
failed: list[tuple[str, str, str]] = []

for _, row in teams.iterrows():
if row.size == 3:
team_name = f"{stem}{row[TEAMS]:02.0f}-{row[NAME].strip().replace(' ', '-')}"
elif row.size == 2:
team_name = f"{stem}{row[TEAMS]}"
else:
raise ValueError("I expect team number OR team number and team name")
match row.size:
case 3:
team_name = f"{stem}{row[TEAMS]:02.0f}-{row[NAME].strip().replace(' ', '-')}"
case 2:
team_name = f"{stem}{row[TEAMS]}"
case _:
raise ValueError("I expect team number OR team number and team name")

login = row[USERNAME].strip()
try:
Expand Down
2 changes: 1 addition & 1 deletion Github/PlotCommits.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
As a first pass, just shows total LoC changed. Future: plot commit vs. time.
"""

from __future__ import annotations

import argparse
from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = ["Development Status :: 5 - Production/Stable",
"Topic :: Software Development :: Version Control :: Git",
"Topic :: Utilities"
]
requires-python = ">=3.9"
requires-python = ">=3.10"
dynamic = ["readme","version"]
dependencies = ["pygithub >= 1.53", "pandas"]

Expand Down
2 changes: 1 addition & 1 deletion src/gitbulk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The "classic" Oauth does work for organizations.
"""

from __future__ import annotations

from pathlib import Path
from datetime import datetime
import logging
Expand Down
1 change: 0 additions & 1 deletion src/gitbulk/duplicator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import annotations
from time import sleep
from pathlib import Path
import subprocess
Expand Down
1 change: 0 additions & 1 deletion src/gitbulk/get.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import annotations
import re

import github
Expand Down
2 changes: 1 addition & 1 deletion src/gitbulk/repo_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
How many total GitHub stars do you have?
"""

from __future__ import annotations

from time import sleep
from pathlib import Path
import github
Expand Down

0 comments on commit 92efd8c

Please sign in to comment.