Skip to content

Commit

Permalink
Initial pre-release (v0.0.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimboump committed Aug 28, 2023
1 parent ee70cd5 commit 4b5d4cf
Show file tree
Hide file tree
Showing 11 changed files with 561 additions and 3 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
permissions: write-all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # This ensures all commits and tags are fetched

- name: Generate release notes
id: release_notes
run: |
TAG_NAME=${{ github.ref_name }}
LATEST_SHA=$(gh release view latest --json publishedAt -q ".publishedAt") || true
if [ -z "$LATEST_SHA" ]; then
NOTES=$(git log --pretty=format:"%s" $(git rev-list --max-parents=0 HEAD)..HEAD)
else
NOTES=$(git log --pretty=format:"%s" $LATEST_SHA..HEAD)
fi
INTRO="Version $TAG_NAME contains the following changes and improvements:"
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "text<<EOF"$'\n'"$INTRO"$'\n'"$NOTES"$'\n'EOF >> $GITHUB_OUTPUT
- name: Create Release
run: |
TAG_NAME=${{ github.ref_name }}
gh release create $TAG_NAME -t $TAG_NAME -n "${{ steps.release_notes.outputs.notes }}" --target main
- name: Move 'latest' tag
run: |
git tag -d latest || true # Delete local 'latest' tag if exists
git push origin :refs/tags/latest || true # Delete remote 'latest' tag if exists
git tag latest
git push origin refs/tags/latest
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.vscode/
.venv/
venv/
__pycache__/
.mypy_cache/
.ipynb_checkpoints/
*.egg-info/
testing/

*.csv
*.xls
*.xlsx
*.pkl
*.log
*.old
27 changes: 25 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
name: Trim Trailing Whitespace
- id: end-of-file-fixer
name: Fix End of Files
- id: check-yaml
name: Check YAML
- id: check-added-large-files
name: Check for added large files
- id: detect-private-key
name: Detect Private Key
- id: check-merge-conflict
name: Check for merge conflicts
- id: requirements-txt-fixer
name: Fix `requirements.txt`
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.10.0
hooks:
- id: reorder-python-imports
name: Reorder Python Imports
- repo: https://github.com/pyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
name: Flake8
args: [--max-line-length=80, --ignore=E226, --extend-ignore=E501]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# tcc-stats
# Statistics for TCC

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit) [![Create Release](https://github.com/dimboump/tcc-stats/actions/workflows/releases.yaml/badge.svg)](https://github.com/dimboump/tcc-stats/actions/workflows/releases.yaml)

## Installation and Usage

1. Clone the repository:

```bash
git clone git@github.com:dimboump/tcc-stats
```

2. Install the dependencies and run the script:

- Windows:

```bash
pip install -r requirements.txt
python tcc_stats.py
```

- Linux/macOS:

```bash
pip3 install -r requirements.txt
python3 tcc_stats.py
```

Options:

| Option | Data Type | Description | Default |
| ------ | --------- | ----------- | ------- |
| `-p`, `--path` | `str` or `pathlib.Path` | Path to or name of the TCC data directory. | `data/` |
| `-y`, `--years` | `int`, `Sequence[int]` | Years to include in the statistics. You can specify a single year or multiple years, by separating them with a space. | 2018-today |
| `-m`, `--months` | `int`, `Sequence[int]` | Months to include in the statistics. To specify multiple months, separate them with a comma. | 12 months if the year is in the past, current month since January of this year otherwise |
| `-o`, `--output` | `str` or `pathlib.Path` | Path to or name of the output file (with extension). Can also be an Excel file (`.xlsx`, `.xls`). If the path/file doens't exist, it will be created or, if it does, will be overwritten. | `export.csv` |
| `-v`, `--verbose` | `bool` | Print more information about the data, along with a small sample (max 10 rows) before and after preprocessing. | False |
| `-h`, `--help` | &ndash; | Show help message and exit. | &ndash; |
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mypy
pytest
pytest-env
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
matplotlib
openpyxl
pandas
37 changes: 37 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[metadata]
name = tcc-stats
version = 1.0.0
description = A Python package for generating statistics from TCC data
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/dimboump/tcc-stats
author = Dimitris Boumparis
author_email = dimitris@dimboump.dev
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython

[options]
packages = find:
install_requires =
pandas>=1.0.0
matplotlib>=3.0.0
numpy>=1.0.0
python_requires = >=3.8

[options.packages.find]
exclude =
tests*
testing*

[options.entry_points]
console_scripts =
tcc-stats = tcc_stats.main:main

[tool:pytest]
testpaths = tests

[flake8]
max-line-length = 80
ignore = E266, E501
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from setuptools import setup

setup()
Empty file added tcc_stats/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions tcc_stats/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from __future__ import annotations

from tcc_stats.main import main

if __name__ == '__main__':
raise SystemExit(main())
Loading

0 comments on commit 4b5d4cf

Please sign in to comment.