Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
simontaurus committed May 18, 2024
1 parent e456db5 commit dd835ba
Show file tree
Hide file tree
Showing 7 changed files with 6,294 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will upload a Python Package when a release is created


name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install .[dev]
- name: Test with pytest
run: |
pip install pytest
pytest
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will run pytest only

name: Run pytest

on:
push:
pull_request:
workflow_dispatch:


permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Test with pytest
run: |
pytest
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# handlebars-py
handlebars.js transpiled to python with js2py
[handlebars.js](https://github.com/handlebars-lang/handlebars.js) transpiled to python with [js2py](https://github.com/PiotrDabkowski/Js2Py)

## Usage
```python
#!pip install handlebars
from handlebars import Handlebars
template = Handlebars.compile( "Name: {{name}}" )
template({ "name": "Jane" })
# returns: 'Name: Jane'
```


## Development
```bash
pip install -e .[dev]
```
89 changes: 89 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[build-system]
requires = [
"setuptools>=61.0.0",
"setuptools-scm>=8.0",
]
build-backend = "setuptools.build_meta"

[project]
name = "handlebars"
dynamic = ["version"]
description = "handlebars.js transpiled to python with js2py"
readme = "README.md"
authors = [
{ name = "Simon Stier", email = 'simon.stier@gmx.de' },
{ name = "handlebars.js contributors" }
]
maintainers = [
{ name = "Simon Stier", email = 'simon.stier@gmx.de' }
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"js2py",
]
[project.optional-dependencies]
dev = [
"pytest",
"requests",
]

[project.license]
file = "LICENSE"

[project.urls]
"Homepage" = "https://github.com/opensemanticworld/handlebars-py"
"Bug Tracker" = "https://github.com/opensemanticworld/handlebars-py"

[tool.ruff]
include = ["src/*.py", "tests/*.py"]
select = [
"E", # pycodestyle
"W", # pycodestyle
"PL", # pylint
]
ignore = [
"E501", # Line too long ({width} > {limit} characters)
"E701", # Multiple statements on one line (colon)
"E731", # Do not assign a lambda expression, use a def
"E402", # Module level import not at top of file
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0915", # Too many statements
"PLR2004", # Magic value used instead of constant
"PLW0603", # Using the global statement
"PLW2901", # redefined-loop-name
"PLR1714", # consider-using-in
"PLR5501", # else-if-used
]
fixable = ["ALL"]
exclude = ["dependencies"]

# Same as Black.
line-length = 88
indent-width = 4

[tool.ruff.format]
# use single quotes for strings.
quote-style = "single"

# indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.setuptools.packages.find]
where = [
"src",
]

[tool.setuptools_scm]
3 changes: 3 additions & 0 deletions src/handlebars/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .handlebars_js import handlebars_js
Handlebars = handlebars_js.Handlebars

Loading

0 comments on commit dd835ba

Please sign in to comment.