Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump actions/setup-python from 2 to 4 #3

Merged
merged 12 commits into from
Aug 10, 2023
4 changes: 3 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: pre-commit/action@v2.0.3
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
matrix:
os:
- ubuntu-latest
python-version: ["3.6", "3.7", "3.8", "3.9"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run tox with tox-gh-actions
uses: ymyzk/run-tox-gh-actions@main
with:
tox-version: ">=4"
tox-version: "'>=4'"
68 changes: 36 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ description = "Script to check Gmail messages & populate waybar widget with data
readme = "README.md"
requires-python = ">=3.0"
license = { file = "LICENSE" }
keywords = ["waybar", "gmail", "wayland", "sway", "inbox"]
keywords = ["gmail", "inbox", "sway", "waybar", "wayland"]
authors = [{ name = "James Cuzella", email = "james.cuzella@lyraphase.com" }]
maintainers = [
{ name = "James Cuzella", email = "james.cuzella@lyraphase.com" },
]
maintainers = [{ name = "James Cuzella", email = "james.cuzella@lyraphase.com" }]
classifiers = [
"Development Status :: 1 - Planning",
"Programming Language :: Python",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Topic :: Communications :: Email",
"Topic :: Desktop Environment :: Window Managers :: Sway",
"Topic :: Utilities",
Expand All @@ -27,25 +25,28 @@ classifiers = [
dependencies = ["filelock ~= 3.12", "httplib2 ~= 0.22", "oauth2client ~= 4.1"]


[project.urls]
Homepage = "https://github.com/LyraPhase/waybar-check-gmail"
Documentation = "https://github.com/LyraPhase/waybar-check-gmail"
Repository = "https://github.com/LyraPhase/waybar-check-gmail.git"
Changelog = "https://github.com/LyraPhase/waybar-check-gmail/blob/master/CHANGELOG.md"
[project.urls]
Homepage = "https://github.com/LyraPhase/waybar-check-gmail"
Documentation = "https://github.com/LyraPhase/waybar-check-gmail"
Repository = "https://github.com/LyraPhase/waybar-check-gmail.git"
Changelog = "https://github.com/LyraPhase/waybar-check-gmail/blob/master/CHANGELOG.md"

[project.scripts]
waybar-check-gmail-cli = "waybar-check-gmail:main_cli"

[project.gui-scripts]
waybar-check-gmail-gui = "waybar-check-gmail:main_gui"
#[project.scripts]
#waybar-check-gmail-cli = "waybar_check_gmail:main_cli"

#[project.gui-scripts]
#waybar-check-gmail-gui = "waybar_check_gmail:main_gui"



[tool.isort]
multi_line_output = 3
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
line_length = 90
profile = "black"
force_grid_wrap = 0
line_length = 90
profile = "black"

# TODO: tox4 config?
# Ref: https://github.com/tox-dev/tox/issues/999

Expand All @@ -57,6 +58,13 @@ requires =
#env_list = linters, type, py{38,39,310,311}
env_list = linters, py{38,39,310,311}

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
description = run tests
deps =
Expand Down Expand Up @@ -148,32 +156,28 @@ exclude = '''
'''
# Targeting future versions as well so we don't have black reformatting code
# en masse later.
target_version = ["py37", "py38", "py39", "py310", "py311"]
target_version = ["py310", "py311", "py37", "py38", "py39"]

[tool.bandit]
exclude_dirs = [
".tox",
"tests",
".vscode",
"coverage-*",
"*.egg-info",
"*.pyc",
"__pycache__",
".pytest_cache",
".tox",
".vscode",
"__pycache__",
"coverage-*",
"test-results*",
"tests",
]

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]
pythonpath = [
".", "src",
]
addopts = ["--import-mode=importlib"]
pythonpath = [".", "src"]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"serial",
"great: It's not good, not bad, but somewhat better than good? ¯\\_(ツ)_/¯",
"serial",
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
]

# TODO: test coverage setup
Expand Down
44 changes: 44 additions & 0 deletions src/waybar_check_gmail/util/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import pathlib
import stat
import sys
import textwrap


def msgfmt(msg, prefix=""):
lines = []
for line in msg.splitlines():
lines += textwrap.wrap(line, 80 - len(prefix))
return "\n".join([prefix + line for line in lines])


def warn(msg):
print(msgfmt(msg, "warning: "))


def die(msg):
sys.exit(msgfmt(msg, "error: "))


def mkdir_p(dir):
try:
pathlib.Path(dir).mkdir(parents=True, exist_ok=True)
except FileExistsError:
die("{} is not a directory".format(dir))


def is_group_or_other_writable(f):
st = os.stat(f)
return bool(st.st_mode & (stat.S_IWGRP | stat.S_IWOTH))


def is_group_or_other_readable(f):
st = os.stat(f)
return bool(st.st_mode & (stat.S_IRGRP | stat.S_IROTH))


def check_runtime_dir(dir):
try:
pathlib.Path(dir)
except FileExistsError:
die("{} is not a directory".format(dir))
11 changes: 4 additions & 7 deletions src/waybar_check_gmail/util/xdg_base_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):

def __repr__(self):
return (
"%s(xdg_config_home=%s, xdg_data_home=%s, xdg_cache_home=%s,"
"xdg_state_home=%s, xdg_runtime_dir=%s)" % self.__class__.__name__,
self.xdg_config_home,
self.xdg_data_home,
self.xdg_cache_home,
self.xdg_state_home,
self.xdg_runtime_dir,
f"{self.__class__.__name__}(xdg_config_home={self.xdg_config_home}, "
f"xdg_data_home={self.xdg_data_home}, xdg_cache_home={self.xdg_cache_home}, "
f"xdg_state_home={self.xdg_state_home}, "
f"xdg_runtime_dir={self.xdg_runtime_dir})"
)
4 changes: 4 additions & 0 deletions src/waybar_check_gmail/waybar_check_gmail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python3

# Constants
PROGRAM_NAME = "waybar-check-gmail"