Skip to content

Commit

Permalink
Merge pull request #5 from valohai/renovate-2024
Browse files Browse the repository at this point in the history
Renovations, spring 2024
  • Loading branch information
akx authored May 20, 2024
2 parents 7945a2f + f40146f commit 5baf069
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 73 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ci
"on":
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v4
- uses: pre-commit/[email protected]
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v4
- run: pip install build
- run: python -m build
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace
- id: mixed-line-ending
args:
- --fix=lf
- repo: https://github.com/crate-ci/typos
rev: v1.21.0
hooks:
- id: typos
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
G Suite Tools
=============
# G Suite Tools

A growing collection tools for managing a G Suite organization.

Before you begin
----------------
## Before you begin

* Install the requirements into a Python 3.8+ virtualenv. (`pip install -r requirements.txt`)
* Set up an OAuth application for Google APIs.
- Install the requirements into a Python 3.8+ virtualenv. (`pip install -e .`)
- Set up an OAuth application for Google APIs.
Follow the instructions on [this page](https://developers.google.com/admin-sdk/directory/v1/guides/authorizing.html)
for "installed software" authentication and once you have a `client_secret.json` file, plop it in the
working directory here.

Retrieve all groups and their members
-------------------------------------
## Retrieve all groups and their members

```
python -m gst.get_group_info --domain=mydomain.com --write-json=groups.json
Expand All @@ -31,17 +28,14 @@ To convert `groups.json` into human-readable Markdown:
python -m gst.format_group_info --json=groups.json --write-markdown=-
```

Retrieve information for all users
----------------------------------

## Retrieve information for all users

```
python -m gst.get_user_info --domain=mydomain.com --write-json=users.json
```

To list users with their email aliases:


```
python -m gst.list_user_emails --json=groups.json -w-
```
1 change: 1 addition & 0 deletions gst/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
4 changes: 4 additions & 0 deletions gst/credentials.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import logging
import os
import pickle

from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build

log = logging.getLogger(__name__)


def get_credentials(key, scopes):
cached_credentials_file = f"./{key}.credentials.pickle"
if os.path.isfile(cached_credentials_file):
log.info("Using cached credentials from %s", cached_credentials_file)
with open(cached_credentials_file, "rb") as infp:
return pickle.load(infp)
flow = InstalledAppFlow.from_client_secrets_file(
Expand Down
42 changes: 42 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "g-suite-tools"
dynamic = ["version"]
description = 'Tools for managing G Suites'
readme = "README.md"
requires-python = ">=3.8"
license = "MIT"
keywords = []
authors = [
{ name = "Aarni Koskela", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"google-api-python-client~=1.7",
"google-auth-oauthlib~=0.4",
"tqdm~=4.38",
]

[project.urls]
Documentation = "https://github.com/valohai/g-suite-tools#readme"
Issues = "https://github.com/valohai/g-suite-tools/issues"
Source = "https://github.com/valohai/g-suite-tools"

[tool.hatch.version]
path = "gst/__init__.py"

[tool.hatch.build.targets.wheel]
packages = ["gst"]
3 changes: 0 additions & 3 deletions requirements.in

This file was deleted.

58 changes: 0 additions & 58 deletions requirements.txt

This file was deleted.

0 comments on commit 5baf069

Please sign in to comment.