Exemplo n.º 1
0
def main(oauth: Path, orgname: str, stem: str):
    # %% authentication
    user, sess = gb.connect(oauth)
    assert isinstance(user, github.AuthenticatedUser.AuthenticatedUser
                      ), "unwatch is for users only, not orgs"
    gb.check_api_limit(sess)
    # %% get organization handle
    org = gb.user_or_org(sess, orgname)
    # %% prepare to loop over repos
    repos = gb.get_repos(org)

    to_act = [
        repo for repo in repos
        if user.has_in_watched(repo) and repo.name.startswith(stem)
    ]
    if not to_act:
        raise SystemExit(
            f"There were no repos left to unwatch with {stem} in {orgname}")

    print("\ntype affirmative to UNWATCH",
          "\n".join([repo.full_name for repo in to_act]))
    if input() != "affirmative":
        raise SystemExit("Aborted")

    for repo in to_act:
        user.remove_from_watched(repo)
        print("UnWatched:", repo.full_name)
Exemplo n.º 2
0
def main():
    p = ArgumentParser(description="mass add team members to repos, optionally creating new repos")
    p.add_argument("fn", help=".xlsx with group info")
    p.add_argument("oauth", help="Oauth file")
    p.add_argument("-stem", help="beginning of repo names", default="")
    p.add_argument("-orgname", help="Github Organization", required=True)
    p.add_argument("-col", help="columns for Username, teamname", nargs="+", required=True)
    p.add_argument("-private", help="create private repos", action="store_true")
    p.add_argument("-create", help="create repo if not existing", action="store_true")
    p = p.parse_args()

    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}")

    if not teams.ndim == 2:
        raise ValueError(
            "need to have member names and team names. Check that -col argument matches spreadsheet."
        )
    # %%
    op, sess = connect(p.oauth, p.orgname)
    check_api_limit(sess)

    adder(teams, p.stem, p.private, p.create, op, sess)
Exemplo n.º 3
0
def main():
    p = ArgumentParser(
        description=
        "mass add team members to repos, optionally creating new repos")
    p.add_argument("fn", help=".xlsx with group info")
    p.add_argument("oauth", help="Oauth file")
    p.add_argument("-orgname", help="Github Organization", required=True)
    p.add_argument("-col",
                   help="column for GitHub Username",
                   nargs="+",
                   required=True)
    p = p.parse_args()

    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}")

    if not users.ndim == 1:
        raise ValueError(
            "need to have member names. Check that -col argument matches spreadsheet."
        )
    # %%
    op, sess = connect(p.oauth, p.orgname)
    check_api_limit(sess)

    adder(users, op, sess)
Exemplo n.º 4
0
def main():
    p = ArgumentParser(description="mass create repos for teams")
    p.add_argument("fn", help=".xlsx with group info")
    p.add_argument("oauth", help="Oauth file")
    p.add_argument("orgname", help="Github Organization")
    p.add_argument("-stem", help="beginning of repo names", default="")
    p.add_argument(
        "-col", help="column(s) for TeamName OR TeamNumber, TeamName", nargs="+", required=True
    )
    p.add_argument("-private", help="create private repos", action="store_true")
    p = p.parse_args()

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

    teams = pandas.read_excel(fn, usecols=",".join(p.col)).squeeze().dropna().drop_duplicates()
    # %%
    op, sess = connect(p.oauth, p.orgname)
    check_api_limit(sess)

    if teams.ndim == 1:
        by_num(teams, p.stem, p.private, op, sess)
    elif teams.shape[1] == 2:
        by_name(teams, p.stem, p.private, op, sess)
Exemplo n.º 5
0
def main(P):
    op, sess = connect(P.oauth, P.orgname)
    check_api_limit(sess)

    return get_collabs(op, sess, P.stem, P.regex)