Skip to content

Commit

Permalink
Release 1.0.0 (#58)
Browse files Browse the repository at this point in the history
* Fix minor doc typo

"Litaral" -> "Literal"

* Switched broken pypip.in badges to shields.io

* Updating cli docs

* add funding button

* Add nix shell, confirm works on Python 3.9

* Shell, python310

* remove python2 from CI

* Switch CI

* add requires.io badge

* switch to pytest, forget python2

* pytest

* fix rst tests

* install stylus before tests

* f

* fix coveralls

* add coverage

* Version bump

* changelog

* incorporate Pull request #55

Co-authored-by: Tom X. Tobin <[email protected]>
Co-authored-by: Michael Overmeyer <[email protected]>
Co-authored-by: Stephen <[email protected]>
  • Loading branch information
4 people authored Sep 16, 2022
1 parent 5f62ab6 commit 84a80ff
Show file tree
Hide file tree
Showing 28 changed files with 270 additions and 107 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [avanov]
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "CI"
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

jobs:
tests:
strategy:
matrix:
python-version: [ 39, 310 ]
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- uses: cachix/install-nix-action@v12
with:
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
extra_nix_config: "system-features = benchmark kvm"
- name: Run tests on Python${{ matrix.python-version }}
run: |
nix-shell --argstr pyVersion ${{ matrix.python-version }} --run \
"pip install -e . && pip install -r requirements.txt && pip install -r requirements-test.txt && python -m pytest"
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
nix-shell --argstr pyVersion ${{ matrix.python-version }} --run "coveralls --service=github"
coveralls:
name: Coveralls [finalize]
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
submodules: recursive
- uses: cachix/install-nix-action@v12
with:
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
extra_nix_config: "system-features = benchmark kvm"
- name: Coveralls [finalize]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
nix-shell --run "coveralls --service=github --finish"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
build/
dist/
*.egg-info/
*.eggs/
*.local/
__pycache__/
# npm package lock, we don't need it as the 'stylus' dependency is optional
package-lock.json

docs/_build

Expand Down
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
================

1.0.0
-----

- Dropped support for Python 2.x
- Test suite switched from Nose to Pytest
- CI switched from Travis CI to Github Actions

Version 0.9
-------------

Expand Down
19 changes: 10 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
Plim
==============

.. image:: https://pypip.in/v/Plim/badge.png
.. image:: https://img.shields.io/pypi/v/Plim.svg
:target: https://crate.io/packages/Plim

.. image:: https://pypip.in/d/Plim/badge.png
:target: https://crate.io/packages/Plim
.. image:: https://requires.io/github/avanov/Plim/requirements.svg?branch=master
:target: https://requires.io/github/avanov/Plim/requirements/?branch=master
:alt: Requirements Status

.. image:: https://api.travis-ci.org/avanov/Plim.png
:target: https://travis-ci.org/avanov/Plim
.. image:: https://img.shields.io/pypi/dm/Plim.svg
:target: https://crate.io/packages/Plim

.. image:: https://coveralls.io/repos/avanov/Plim/badge.png?branch=develop
:target: https://coveralls.io/r/avanov/Plim?branch=develop
.. image:: https://github.com/avanov/Plim/workflows/CI/badge.svg?branch=develop
:target: https://github.com/avanov/Plim/actions?query=branch%3Adevelop

.. image:: https://gemnasium.com/avanov/Plim.svg
:target: https://gemnasium.com/avanov/Plim
.. image:: https://coveralls.io/repos/github/avanov/Plim/badge.svg?branch=develop
:target: https://coveralls.io/github/avanov/Plim?branch=develop


Plim is a Python port of `Ruby's Slim template language <http://slim-lang.com/>`_
Expand Down
67 changes: 67 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# https://nixos.wiki/wiki/Development_environment_with_nix-shell
{ pkgs ? (import ./nixpkgs).pkgs
, pyVersion ? "310"
}:

let

python = pkgs."python${pyVersion}Full";
pythonPkgs = pkgs."python${pyVersion}Packages";

devEnv = pkgs.mkShellNoCC {
name = "plim-devenv";

# The packages in the `buildInputs` list will be added to the PATH in our shell
# Python-specific guide:
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md
nativeBuildInputs = with pkgs; [
# see https://nixos.org/nixos/packages.html
# Python distribution
python
pythonPkgs.virtualenv
pythonPkgs.wheel
pythonPkgs.twine
pythonPkgs.coveralls

nodejs
nodePackages.npm
taglib
ncurses
libxml2
libxslt
libzip
zlib
# root CA certificates
cacert
which
];
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
export SOURCE_DATE_EPOCH=$(date +%s)
VENV_DIR=$PWD/.venv
export PATH=$VENV_DIR/bin:$PATH
export PYTHONPATH=""
export LANG=en_GB.UTF-8
# https://python-poetry.org/docs/configuration/
export PIP_CACHE_DIR="$PWD/.local/pip-cache${pyVersion}"
# Setup virtualenv
if [ ! -d $VENV_DIR ]; then
virtualenv $PWD/.venv
$VENV_DIR/bin/python -m pip install -e $PWD
$VENV_DIR/bin/python -m pip install -r $PWD/requirements.txt
fi
if [ ! -d $PWD/node_modules ]; then
npm install stylus
fi
'';
};

in
{
inherit devEnv;
}
13 changes: 10 additions & 3 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ source files into Mako templates.
.. code-block:: shell
$ plimc -h
usage: plimc [-h] [--encoding ENCODING] source target
usage: plimc [-h] [-o OUTPUT] [-e ENCODING] [-p PREPROCESSOR] [-H] [-V] source
Compile plim source files into mako files.
positional arguments:
source path to source plim template
target path to target mako template
optional arguments:
-h, --help show this help message and exit
--encoding ENCODING source file encoding
-o OUTPUT, --output OUTPUT
write result to FILE.
-e ENCODING, --encoding ENCODING
content encoding
-p PREPROCESSOR, --preprocessor PREPROCESSOR
Preprocessor instance that will be used for parsing
the template
-H, --html Render HTML output instead of Mako template
-V, --version show program's version number and exit
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '0.9'
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '0.9.12'
release = '1.0.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/differences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Plim is *not the exact* port of Slim. Here is the full list of differences.
#. In Plim, all html tags **MUST** be written in lowercase.

This restriction was introduced to support
:ref:`Implicit Litaral Blocks <implicit-literals>` feature.
:ref:`Implicit Literal Blocks <implicit-literals>` feature.

.. code-block:: slim
Expand Down
7 changes: 4 additions & 3 deletions docs/frameworks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ settings dictionary. The default prefix is 'mako.'.
Flask
======

The following code snippet would get Flask working with plim:
First install the flask_mako package. The following code snippet would get Flask working with plim:

.. code-block:: python
from flask import Flask
from flask.ext.mako import MakoTemplates, render_template
from flask_mako import MakoTemplates, render_template
from plim import preprocessor
app = Flask(__name__)
app = Flask(__name__, template_folder='.')
mako = MakoTemplates(app)
app.config['MAKO_PREPROCESSOR'] = preprocessor
Expand All @@ -47,6 +47,7 @@ The following code snippet would get Flask working with plim:
if __name__ == "__main__":
app.run(debug=True)
With hello.html in templates dir:

.. code-block:: html
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ Tests
=======

Plim provides an extensive test suite based on
`nosetests <http://nose.readthedocs.org/en/latest/>`_.
`pytest <https://pytest.org/>`_.
You can run the tests with the following command

.. code-block:: bash
python setup.py nosetests
python -m pytest
Coverage statistics are `available online <https://coveralls.io/r/avanov/Plim?branch=develop>`_.

Expand Down
2 changes: 1 addition & 1 deletion docs/locale/differences.pot
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ msgstr ""

#: ../differences.rst:63
# 2a470b5d41b548dda64bed052f282a56
msgid "This restriction was introduced to support :ref:`Implicit Litaral Blocks <implicit-literals>` feature."
msgid "This restriction was introduced to support :ref:`Implicit Literal Blocks <implicit-literals>` feature."
msgstr ""

#: ../differences.rst:79
Expand Down
4 changes: 2 additions & 2 deletions docs/locale/zh_CN/LC_MESSAGES/differences.po
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ msgstr "Plim 中,所有 HTML 标签 **必须** 完全小写:"

#: ../differences.rst:63
msgid ""
"This restriction was introduced to support :ref:`Implicit Litaral Blocks "
"This restriction was introduced to support :ref:`Implicit Literal Blocks "
"<implicit-literals>` feature."
msgstr ""
"该限制是为了提供 :ref:`隐式纯文本块(Implicit Litaral Blocks) <implicit-literals>` 功能。"
"该限制是为了提供 :ref:`隐式纯文本块(Implicit Literal Blocks) <implicit-literals>` 功能。"

#: ../differences.rst:79
msgid ""
Expand Down
12 changes: 12 additions & 0 deletions nixpkgs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let

common-src = builtins.fetchTarball {
name = "common-2022-09-15";
url = https://github.com/avanov/nix-common/archive/6e47c05632c781e0279f4b4609fb4125e4e7bf67.tar.gz;
# Hash obtained using `nix-prefetch-url --unpack <url>`
sha256 = "sha256:1av8r2wn4nqwldkkmij4pig9x4nhii7x053i0bd1ngi66kxdkxhr";
};

in

import common-src { projectOverlays = []; }
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"stylus": "^0.59.0"
}
}
5 changes: 1 addition & 4 deletions plim/adapters/babelplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from mako.ext.babelplugin import extract as _extract_mako

from .. import preprocessor_factory
from ..util import StringIO, PY3K
from ..util import StringIO


def extractor_factory(preprocessor=None):
Expand All @@ -22,9 +22,6 @@ def babel_extractor(fileobj, keywords, comment_tags, options):
:rtype: ``iterator``
"""
raw_data = fileobj.read()
if not PY3K:
encoding = options.get('input_encoding', options.get('encoding', 'utf-8'))
raw_data = raw_data.decode(encoding)
data = preprocessor(raw_data)
for extracted in _extract_mako(StringIO(data), keywords, comment_tags, options):
yield extracted
Expand Down
4 changes: 1 addition & 3 deletions plim/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from mako.template import Template
from mako.lookup import TemplateLookup

from .util import PY3K


def plimc(args=None, stdout=None):
"""This is the `plimc` command line utility
Expand Down Expand Up @@ -65,7 +63,7 @@ def plimc(args=None, stdout=None):
# ------------------------------------
if args.output is None:
if stdout is None:
stdout = PY3K and sys.stdout.buffer or sys.stdout
stdout = sys.stdout.buffer
fd = stdout
content = codecs.encode(content, 'utf-8')
else:
Expand Down
29 changes: 12 additions & 17 deletions plim/syntax.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import re

from . import lexer as l
from .util import PY3K


if PY3K:
PARSE_IMPLICIT_LITERAL_RE = re.compile(
# Order matters
'(?P<line>(?:'
'\$?\{|\(|\[|&.+;|[0-9]+|'
'(?:'
'[^\u0021-\u007E]' # not ASCII 33 - 126
'|' # or
'[A-Z]' # uppercase latin letters (ASCII 65 - 90)
')' # It is possible because TAG_RE can match only lowercase tag names
').*)\s*'
)
else:
from .unportable import PARSE_IMPLICIT_LITERAL_RE

PARSE_IMPLICIT_LITERAL_RE = re.compile(
# Order matters
'(?P<line>(?:'
'\$?\{|\(|\[|&.+;|[0-9]+|'
'(?:'
'[^\u0021-\u007E]' # not ASCII 33 - 126
'|' # or
'[A-Z]' # uppercase latin letters (ASCII 65 - 90)
')' # It is possible because TAG_RE can match only lowercase tag names
').*)\s*'
)


class BaseSyntax(object):
Expand Down
Loading

0 comments on commit 84a80ff

Please sign in to comment.