diff --git a/.gitignore b/.gitignore index 3bbe7b6..af2f537 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,104 @@ +# Byte-compiled / optimized / DLL files __pycache__/ -*.pyc -*.pyo +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +.static_storage/ +.media/ +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9492abb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] +Initial release diff --git a/README.md b/README.md new file mode 100644 index 0000000..15ff479 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# mmcli + + + +## Development +To create a virtualenv and install the dependencies in it: +``` +tools/create_venv.sh +``` + +Activate the virtualenv with `source venv/bin/activate`. To make this easier, you could create +an [alias][] `alias venv='source venv/bin/activate'` in your shell. + +[alias]: https://www.computerworld.com/article/2598087/how-to-use-aliases-in-linux-shell-commands.html + +If you introduce dependencies, list them in `pyproject.toml` under `dependencies`, and run +`tools/update_requirements.sh`. diff --git a/mmcli/__init__.py b/mmcli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mmcli.py b/mmcli/mmcli.py similarity index 99% rename from mmcli.py rename to mmcli/mmcli.py index 39e5890..e878942 100755 --- a/mmcli.py +++ b/mmcli/mmcli.py @@ -9,9 +9,9 @@ import re from time import sleep import threading import mattermost -from parsedt import parse_datetime_to_utc +from .parsedt import parse_datetime_to_utc -from mmws import MMws +from .mmws import MMws class NotFound(Exception): diff --git a/mmws.py b/mmcli/mmws.py similarity index 100% rename from mmws.py rename to mmcli/mmws.py diff --git a/parsedt.py b/mmcli/parsedt.py similarity index 100% rename from parsedt.py rename to mmcli/parsedt.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..028c55b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[project] +name = "mmcli" +version = "0.0.1" +authors = [ + { name="Midgard", email="midgard@zeus.ugent.be" }, +] +description = "Mattermost command-line interface" +readme = "README.md" + +# Choose from the list at https://pypi.org/classifiers/ +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Operating System :: OS Independent", + "Natural Language :: English", + "Environment :: Console", + + #"Development Status :: 1 - Planning", + #"Development Status :: 2 - Pre-Alpha", + "Development Status :: 3 - Alpha", + #"Development Status :: 4 - Beta", + #"Development Status :: 5 - Production/Stable", + #"Development Status :: 6 - Mature", + #"Development Status :: 7 - Inactive", + + "Intended Audience :: End Users/Desktop", + "Topic :: Utilities", +] + +requires-python = ">=3.7" +dependencies = [ + "python-dateutil >= 2.8.2, < 3.0.0", + "mattermost >= 5.33.0", +] + +[project.urls] +#"Homepage" = "" +"Source" = "https://git.zeus.gent/midgard/mmcli" +"Change log" = "https://git.zeus.gent/midgard/mmcli/-/blob/master/CHANGELOG.md" +"Bug tracker" = "https://git.zeus.gent/midgard/mmcli/-/issues" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project.scripts] +# executable-name = "package.subpackage.module:function" +mmcli = "mmcli.mmcli:main" + +[tool.setuptools.packages] +find = {} diff --git a/tools/clean.sh b/tools/clean.sh new file mode 100755 index 0000000..da12cd0 --- /dev/null +++ b/tools/clean.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cd "`dirname "$0"`"/.. +rm -rf ./build/ ./*.egg-info/ ./dist/ ./__pycache__/ ./*/__pycache__/ diff --git a/tools/create_venv.sh b/tools/create_venv.sh new file mode 100755 index 0000000..adb947b --- /dev/null +++ b/tools/create_venv.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +cd "`dirname "$0"`"/.. + +# Create virtualenv +python3 -m virtualenv venv/ +# Install dependencies +venv/bin/pip install -e . diff --git a/tools/release.sh b/tools/release.sh new file mode 100755 index 0000000..1c1469a --- /dev/null +++ b/tools/release.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +cd $(dirname "$0")/.. + +tools/test.sh + +if [ ! -t 0 ] ; then + echo "release.sh should be run with a terminal attached to stdin" >&2 + exit 1 +fi + +git status + +echo -n "Previous version: v" +prev_version="$(python -c 'print(__import__("tomllib").load(open("pyproject.toml", "rb"))["project"]["version"])')" +echo "$prev_version" +read -p "Enter new version: v" version + +tagid=v"$version" +if [ "$version" != "$prev_version" ]; then + sed -i 's/version = ".*"/version = "'"$version"'"/q' pyproject.toml + sed -i 's/## \[Unreleased\]/&\n### Added\n### Changed\n### Deprecated\n### Removed\n### Fixed\n### Security\n\n## ['"$version"'] - '"$(date --utc +%Y-%m-%d)"'/' CHANGELOG.md + echo; echo "Inspect CHANGELOG..." + ${EDITOR:-nano} CHANGELOG.md + git add pyproject.toml CHANGELOG.md + git commit -m "Bump version to $version" + + echo "Creating git tag $tagid" + git tag -s -m "Version $version" "$tagid" +else + echo "Version already created; building wheel and uploading" +fi + +venv/bin/pip install --upgrade build +venv/bin/python -m build + +read -p "Upload to Git and PyPI? (y/N) " confirm +if [ ! "$confirm" = y ]; then "Abort"; exit 1; fi + +python3 -m twine upload dist/*-${version}* +git push origin "$tagid" master diff --git a/tools/update_requirements.sh b/tools/update_requirements.sh new file mode 100755 index 0000000..8e4e3fe --- /dev/null +++ b/tools/update_requirements.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +cd "`dirname "$0"`"/.. + +if [ ! -f venv/bin/pip-compile ]; then + venv/bin/pip install pip-tools +fi + +cat < requirements.txt +# +# This file is autogenerated. To update, run: +# tools/update_requirements.sh +# +EOF +venv/bin/pip-compile --quiet --generate-hashes --annotate --no-header --output-file="-" >> requirements.txt +echo "Updated requirements.txt"