Skip to content

Commit 84a80ff

Browse files
avanovTom X. TobinmovermeyerStephen
authored
Release 1.0.0 (#58)
* 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]>
1 parent 5f62ab6 commit 84a80ff

28 files changed

+270
-107
lines changed

.github/FUNDING.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [avanov]

.github/workflows/ci.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "CI"
2+
on:
3+
push:
4+
branches: [ master, develop ]
5+
pull_request:
6+
branches: [ master, develop ]
7+
8+
jobs:
9+
tests:
10+
strategy:
11+
matrix:
12+
python-version: [ 39, 310 ]
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/[email protected]
16+
with:
17+
submodules: recursive
18+
- uses: cachix/install-nix-action@v12
19+
with:
20+
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
21+
extra_nix_config: "system-features = benchmark kvm"
22+
- name: Run tests on Python${{ matrix.python-version }}
23+
run: |
24+
nix-shell --argstr pyVersion ${{ matrix.python-version }} --run \
25+
"pip install -e . && pip install -r requirements.txt && pip install -r requirements-test.txt && python -m pytest"
26+
27+
- name: Coveralls
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
nix-shell --argstr pyVersion ${{ matrix.python-version }} --run "coveralls --service=github"
32+
33+
coveralls:
34+
name: Coveralls [finalize]
35+
needs: tests
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/[email protected]
39+
with:
40+
submodules: recursive
41+
- uses: cachix/install-nix-action@v12
42+
with:
43+
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
44+
extra_nix_config: "system-features = benchmark kvm"
45+
- name: Coveralls [finalize]
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
nix-shell --run "coveralls --service=github --finish"

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
build/
88
dist/
99
*.egg-info/
10+
*.eggs/
11+
*.local/
12+
__pycache__/
13+
# npm package lock, we don't need it as the 'stylus' dependency is optional
14+
package-lock.json
1015

1116
docs/_build
1217

.travis.yml

-15
This file was deleted.

CHANGES

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
================
33

4+
1.0.0
5+
-----
6+
7+
- Dropped support for Python 2.x
8+
- Test suite switched from Nose to Pytest
9+
- CI switched from Travis CI to Github Actions
10+
411
Version 0.9
512
-------------
613

README.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
Plim
22
==============
33

4-
.. image:: https://pypip.in/v/Plim/badge.png
4+
.. image:: https://img.shields.io/pypi/v/Plim.svg
55
:target: https://crate.io/packages/Plim
66

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

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

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

16-
.. image:: https://gemnasium.com/avanov/Plim.svg
17-
:target: https://gemnasium.com/avanov/Plim
17+
.. image:: https://coveralls.io/repos/github/avanov/Plim/badge.svg?branch=develop
18+
:target: https://coveralls.io/github/avanov/Plim?branch=develop
1819

1920

2021
Plim is a Python port of `Ruby's Slim template language <http://slim-lang.com/>`_

default.nix

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# https://nixos.wiki/wiki/Development_environment_with_nix-shell
2+
{ pkgs ? (import ./nixpkgs).pkgs
3+
, pyVersion ? "310"
4+
}:
5+
6+
let
7+
8+
python = pkgs."python${pyVersion}Full";
9+
pythonPkgs = pkgs."python${pyVersion}Packages";
10+
11+
devEnv = pkgs.mkShellNoCC {
12+
name = "plim-devenv";
13+
14+
# The packages in the `buildInputs` list will be added to the PATH in our shell
15+
# Python-specific guide:
16+
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md
17+
nativeBuildInputs = with pkgs; [
18+
# see https://nixos.org/nixos/packages.html
19+
# Python distribution
20+
python
21+
pythonPkgs.virtualenv
22+
pythonPkgs.wheel
23+
pythonPkgs.twine
24+
pythonPkgs.coveralls
25+
26+
nodejs
27+
nodePackages.npm
28+
taglib
29+
ncurses
30+
libxml2
31+
libxslt
32+
libzip
33+
zlib
34+
# root CA certificates
35+
cacert
36+
which
37+
];
38+
shellHook = ''
39+
# set SOURCE_DATE_EPOCH so that we can use python wheels
40+
export SOURCE_DATE_EPOCH=$(date +%s)
41+
42+
VENV_DIR=$PWD/.venv
43+
44+
export PATH=$VENV_DIR/bin:$PATH
45+
export PYTHONPATH=""
46+
export LANG=en_GB.UTF-8
47+
48+
# https://python-poetry.org/docs/configuration/
49+
export PIP_CACHE_DIR="$PWD/.local/pip-cache${pyVersion}"
50+
51+
# Setup virtualenv
52+
if [ ! -d $VENV_DIR ]; then
53+
virtualenv $PWD/.venv
54+
$VENV_DIR/bin/python -m pip install -e $PWD
55+
$VENV_DIR/bin/python -m pip install -r $PWD/requirements.txt
56+
fi
57+
58+
if [ ! -d $PWD/node_modules ]; then
59+
npm install stylus
60+
fi
61+
'';
62+
};
63+
64+
in
65+
{
66+
inherit devEnv;
67+
}

docs/cli.rst

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@ source files into Mako templates.
99
.. code-block:: shell
1010
1111
$ plimc -h
12-
usage: plimc [-h] [--encoding ENCODING] source target
12+
usage: plimc [-h] [-o OUTPUT] [-e ENCODING] [-p PREPROCESSOR] [-H] [-V] source
1313
1414
Compile plim source files into mako files.
1515
1616
positional arguments:
1717
source path to source plim template
18-
target path to target mako template
1918
2019
optional arguments:
2120
-h, --help show this help message and exit
22-
--encoding ENCODING source file encoding
21+
-o OUTPUT, --output OUTPUT
22+
write result to FILE.
23+
-e ENCODING, --encoding ENCODING
24+
content encoding
25+
-p PREPROCESSOR, --preprocessor PREPROCESSOR
26+
Preprocessor instance that will be used for parsing
27+
the template
28+
-H, --html Render HTML output instead of Mako template
29+
-V, --version show program's version number and exit
2330

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = '0.9'
51+
version = '1.0'
5252
# The full version, including alpha/beta/rc tags.
53-
release = '0.9.12'
53+
release = '1.0.0'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

docs/differences.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Plim is *not the exact* port of Slim. Here is the full list of differences.
6161
#. In Plim, all html tags **MUST** be written in lowercase.
6262

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

6666
.. code-block:: slim
6767

docs/frameworks.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ settings dictionary. The default prefix is 'mako.'.
2828
Flask
2929
======
3030

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

3333
.. code-block:: python
3434
3535
from flask import Flask
36-
from flask.ext.mako import MakoTemplates, render_template
36+
from flask_mako import MakoTemplates, render_template
3737
from plim import preprocessor
3838
39-
app = Flask(__name__)
39+
app = Flask(__name__, template_folder='.')
4040
mako = MakoTemplates(app)
4141
app.config['MAKO_PREPROCESSOR'] = preprocessor
4242
@@ -47,6 +47,7 @@ The following code snippet would get Flask working with plim:
4747
if __name__ == "__main__":
4848
app.run(debug=True)
4949
50+
5051
With hello.html in templates dir:
5152

5253
.. code-block:: html

docs/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ Tests
3838
=======
3939

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

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

docs/locale/differences.pot

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ msgstr ""
5858

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

6464
#: ../differences.rst:79

docs/locale/zh_CN/LC_MESSAGES/differences.po

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ msgstr "Plim 中,所有 HTML 标签 **必须** 完全小写:"
6565

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

7373
#: ../differences.rst:79
7474
msgid ""

nixpkgs/default.nix

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
let
2+
3+
common-src = builtins.fetchTarball {
4+
name = "common-2022-09-15";
5+
url = https://github.com/avanov/nix-common/archive/6e47c05632c781e0279f4b4609fb4125e4e7bf67.tar.gz;
6+
# Hash obtained using `nix-prefetch-url --unpack <url>`
7+
sha256 = "sha256:1av8r2wn4nqwldkkmij4pig9x4nhii7x053i0bd1ngi66kxdkxhr";
8+
};
9+
10+
in
11+
12+
import common-src { projectOverlays = []; }

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"stylus": "^0.59.0"
4+
}
5+
}

plim/adapters/babelplugin.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from mako.ext.babelplugin import extract as _extract_mako
33

44
from .. import preprocessor_factory
5-
from ..util import StringIO, PY3K
5+
from ..util import StringIO
66

77

88
def extractor_factory(preprocessor=None):
@@ -22,9 +22,6 @@ def babel_extractor(fileobj, keywords, comment_tags, options):
2222
:rtype: ``iterator``
2323
"""
2424
raw_data = fileobj.read()
25-
if not PY3K:
26-
encoding = options.get('input_encoding', options.get('encoding', 'utf-8'))
27-
raw_data = raw_data.decode(encoding)
2825
data = preprocessor(raw_data)
2926
for extracted in _extract_mako(StringIO(data), keywords, comment_tags, options):
3027
yield extracted

plim/console.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from mako.template import Template
1212
from mako.lookup import TemplateLookup
1313

14-
from .util import PY3K
15-
1614

1715
def plimc(args=None, stdout=None):
1816
"""This is the `plimc` command line utility
@@ -65,7 +63,7 @@ def plimc(args=None, stdout=None):
6563
# ------------------------------------
6664
if args.output is None:
6765
if stdout is None:
68-
stdout = PY3K and sys.stdout.buffer or sys.stdout
66+
stdout = sys.stdout.buffer
6967
fd = stdout
7068
content = codecs.encode(content, 'utf-8')
7169
else:

plim/syntax.py

+12-17
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
import re
22

33
from . import lexer as l
4-
from .util import PY3K
5-
6-
7-
if PY3K:
8-
PARSE_IMPLICIT_LITERAL_RE = re.compile(
9-
# Order matters
10-
'(?P<line>(?:'
11-
'\$?\{|\(|\[|&.+;|[0-9]+|'
12-
'(?:'
13-
'[^\u0021-\u007E]' # not ASCII 33 - 126
14-
'|' # or
15-
'[A-Z]' # uppercase latin letters (ASCII 65 - 90)
16-
')' # It is possible because TAG_RE can match only lowercase tag names
17-
').*)\s*'
18-
)
19-
else:
20-
from .unportable import PARSE_IMPLICIT_LITERAL_RE
4+
5+
PARSE_IMPLICIT_LITERAL_RE = re.compile(
6+
# Order matters
7+
'(?P<line>(?:'
8+
'\$?\{|\(|\[|&.+;|[0-9]+|'
9+
'(?:'
10+
'[^\u0021-\u007E]' # not ASCII 33 - 126
11+
'|' # or
12+
'[A-Z]' # uppercase latin letters (ASCII 65 - 90)
13+
')' # It is possible because TAG_RE can match only lowercase tag names
14+
').*)\s*'
15+
)
2116

2217

2318
class BaseSyntax(object):

0 commit comments

Comments
 (0)