Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew000 committed Jul 10, 2024
0 parents commit 2daae2d
Show file tree
Hide file tree
Showing 31 changed files with 3,264 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Publish to PyPI

on:
release:
types: [published]


env:
PYTHON_VERSION: "3.12"
POETRY_VERSION: "1.8.3"
POETRY_URL: https://install.python-poetry.org

jobs:
build:
name: 📦 Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
id: setup_python

- name: Cache Poetry cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}

- name: Cache Packages
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-local-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}

- name: Install Poetry
run: |
curl -sSL ${{ env.POETRY_URL }} | python3 - --version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install --only main

- name: Build dist
run: poetry build

- name: Verify wheel installation
run: |
mkdir -p verify
cd verify
python3 -m venv venv
venv/bin/pip install ../dist/*.whl
venv/bin/python -c "import ftl_extract; print(ftl_extract.__version__)"
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish:
name: 🐍 Publish
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/ftl-extract
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
57 changes: 57 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Python package Lint+Test

on:
push:
branches: [ "master", "dev" ]
pull_request:
branches: [ "master", "dev" ]

env:
PYTHON_VERSION: "3.12"
POETRY_VERSION: "1.8.3"
POETRY_URL: https://install.python-poetry.org

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
id: setup_python

- name: Cache Poetry cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}

- name: Cache Packages
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-local-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}

- name: Install Poetry
run: |
curl -sSL ${{ env.POETRY_URL }} | python3 - --version ${{ env.POETRY_VERSION }}
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install --with dev,test

- name: Lint
run: make lint

- name: Test with pytest
run: make test
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.mo
*.pyc
/.env
/.idea/
/.ruff_cache/
/.venv/
/tokei.exe
__pycache__/
*.ftl
/.coverage
/dist/
/docs/
/reports/
/htmlcov/
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: "trailing-whitespace"
- id: "check-case-conflict"
- id: "check-merge-conflict"
- id: "debug-statements"
- id: "end-of-file-fixer"
- id: "mixed-line-ending"
args: [ "--fix", "crlf" ]
types:
- python
- yaml
- toml
- id: "detect-private-key"
- id: "check-yaml"
- id: "check-toml"
- id: "check-json"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.1
hooks:
- id: ruff
args: [ "--fix" ]
files: "ftl_extract"

- id: ruff-format
files: "ftl_extract"

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
files: "ftl_extract"
12 changes: 12 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.10"
jobs:
post_install:
- pip install .[docs]

sphinx:
configuration: docs/source/conf.py
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
code_dir = src
docs_dir = docs
docs_source_dir = $(docs_dir)/source
reports_dir = reports
tests_dir = tests

ifeq ($(OS),Windows_NT)
mkdir_cmd := $(shell if not exist $(reports_dir) mkdir $(reports_dir))
else
mkdir_cmd := $(shell mkdir -p $(reports_dir))
endif

lint:
@echo "Running ruff..."
@poetry run ruff check --config pyproject.toml --diff $(code_dir) $(tests_dir)

@echo "Running MyPy..."
@poetry run mypy --config-file pyproject.toml $(code_dir)

format:
@echo "Running ruff check with --fix..."
@poetry run ruff check --config pyproject.toml --fix $(code_dir) $(tests_dir)

@echo "Running ruff..."
@poetry run ruff format --config pyproject.toml $(code_dir) $(tests_dir)

@echo "Running isort..."
@poetry run isort --settings-file pyproject.toml $(code_dir) $(tests_dir)

livehtml:
@sphinx-autobuild "$(docs_source_dir)" "$(docs_dir)/_build/html" $(SPHINXOPTS) $(O)

test:
@echo "Running tests..."
@poetry run pytest -vv --cov=$(code_dir) --cov-report=html --cov-report=term --cov-config=.coveragerc $(tests_dir)

test-coverage:
@echo "Running tests with coverage..."
@$(mkdir_cmd)
@poetry run pytest -vv --cov=$(code_dir) --cov-config=.coveragerc --html=$(reports_dir)/tests/index.html tests/
@poetry run coverage html -d $(reports_dir)/coverage
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# FTL-Extract

## Description

FTL-Extract is a Python package that extracts Fluent keys from .py files
and generates a .ftl file with extracted keys.

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable) to install
FTL-Extract.

``` bash
pip install FTL-Extract
```

## Usage

``` bash
ftl_extract code_path output_path
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.

Please make sure to update tests as appropriate.
Loading

0 comments on commit 2daae2d

Please sign in to comment.