mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Merge branch 'gh-actions'
This commit is contained in:
commit
dcda895e22
5 changed files with 69 additions and 13 deletions
38
.github/workflows/build.yml
vendored
Normal file
38
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# For more information see: https://docs.github.com/en/actions/guides/building-and-testing-python
|
||||||
|
|
||||||
|
name: Build and test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: '**'
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [2.7, 3.5, 3.7, 3.9, pypy3]
|
||||||
|
# don't cancel every other job if one fails
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install pytest wheel
|
||||||
|
pip install -e .
|
||||||
|
- name: Set up pokedex
|
||||||
|
run: pokedex setup -v
|
||||||
|
- name: Test with pytest
|
||||||
|
run: pytest
|
||||||
|
- name: Dump database and check for differences
|
||||||
|
run: |
|
||||||
|
pokedex dump
|
||||||
|
git --no-pager diff --exit-code pokedex/data/csv/
|
|
@ -21,6 +21,9 @@ def pytest_runtest_setup(item):
|
||||||
if 'slow' in item.keywords and not item.config.getvalue('all'):
|
if 'slow' in item.keywords and not item.config.getvalue('all'):
|
||||||
pytest.skip("skipping slow tests")
|
pytest.skip("skipping slow tests")
|
||||||
|
|
||||||
|
def pytest_configure(config):
|
||||||
|
config.addinivalue_line("markers", "slow: marks tests as slow (require --all to run)")
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def session(request):
|
def session(request):
|
||||||
import pokedex.db
|
import pokedex.db
|
||||||
|
|
|
@ -441,10 +441,12 @@ def dump(session, tables=[], directory=None, verbose=False, langs=None):
|
||||||
|
|
||||||
# CSV module only works with bytes on 2 and only works with text on 3!
|
# CSV module only works with bytes on 2 and only works with text on 3!
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
writer = csv.writer(open(filename, 'w', newline='', encoding="utf8"), lineterminator='\n')
|
csvfile = open(filename, 'w', newline='', encoding="utf8")
|
||||||
|
writer = csv.writer(csvfile, lineterminator='\n')
|
||||||
columns = [col.name for col in table.columns]
|
columns = [col.name for col in table.columns]
|
||||||
else:
|
else:
|
||||||
writer = csv.writer(open(filename, 'wb'), lineterminator='\n')
|
csvfile = open(filename, 'wb')
|
||||||
|
writer = csv.writer(csvfile, lineterminator='\n')
|
||||||
columns = [col.name.encode('utf8') for col in table.columns]
|
columns = [col.name.encode('utf8') for col in table.columns]
|
||||||
|
|
||||||
# For name tables, always dump rows for official languages, as well as
|
# For name tables, always dump rows for official languages, as well as
|
||||||
|
@ -491,4 +493,5 @@ def dump(session, tables=[], directory=None, verbose=False, langs=None):
|
||||||
|
|
||||||
writer.writerow(csvs)
|
writer.writerow(csvs)
|
||||||
|
|
||||||
|
csvfile.close()
|
||||||
print_done()
|
print_done()
|
||||||
|
|
|
@ -11,17 +11,14 @@ which case it is replaced by the name of the thing linked to.
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
import six
|
import six
|
||||||
from sqlalchemy.orm.session import object_session
|
from sqlalchemy.orm.session import object_session
|
||||||
try:
|
from markdown.util import etree, AtomicString
|
||||||
# Markdown 2.1+
|
|
||||||
from markdown.util import etree, AtomicString
|
|
||||||
except ImportError:
|
|
||||||
# Old Markdown
|
|
||||||
from markdown import etree, AtomicString
|
|
||||||
|
|
||||||
@six.python_2_unicode_compatible
|
@six.python_2_unicode_compatible
|
||||||
class MarkdownString(object):
|
class MarkdownString(object):
|
||||||
|
@ -66,8 +63,7 @@ class MarkdownString(object):
|
||||||
extension = self.session.markdown_extension
|
extension = self.session.markdown_extension
|
||||||
|
|
||||||
md = markdown.Markdown(
|
md = markdown.Markdown(
|
||||||
extensions=['extra', extension],
|
extensions=['markdown.extensions.extra', EscapeHtml(), extension],
|
||||||
safe_mode='escape',
|
|
||||||
output_format='xhtml1',
|
output_format='xhtml1',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -164,6 +160,9 @@ class PokedexLinkPattern(markdown.inlinepatterns.Pattern):
|
||||||
|
|
||||||
Handles matches using factory
|
Handles matches using factory
|
||||||
"""
|
"""
|
||||||
|
if sys.version_info >= (3, 6):
|
||||||
|
regex = u'(?x: \\[ ([^]]*) \\] \\{ ([-a-z0-9]+) : ([-a-z0-9 ]+) \\} )'
|
||||||
|
else:
|
||||||
regex = u'(?x) \\[ ([^]]*) \\] \\{ ([-a-z0-9]+) : ([-a-z0-9 ]+) \\}'
|
regex = u'(?x) \\[ ([^]]*) \\] \\{ ([-a-z0-9]+) : ([-a-z0-9 ]+) \\}'
|
||||||
|
|
||||||
def __init__(self, factory, session, string_language=None, game_language=None):
|
def __init__(self, factory, session, string_language=None, game_language=None):
|
||||||
|
@ -228,6 +227,17 @@ class PokedexLinkPattern(markdown.inlinepatterns.Pattern):
|
||||||
el.text = AtomicString(label or name)
|
el.text = AtomicString(label or name)
|
||||||
return el
|
return el
|
||||||
|
|
||||||
|
class EscapeHtml(markdown.Extension):
|
||||||
|
u"""Markdown extension which escapes raw html elements.
|
||||||
|
|
||||||
|
This is the recommended replacement for safe_mode='escape',
|
||||||
|
which was deprecated in Markdown 2.5.
|
||||||
|
See https://python-markdown.github.io/change_log/release-2.5/
|
||||||
|
"""
|
||||||
|
def extendMarkdown(self, md, md_globals):
|
||||||
|
del md.preprocessors['html_block']
|
||||||
|
del md.inlinePatterns['html']
|
||||||
|
|
||||||
class PokedexLinkExtension(markdown.Extension):
|
class PokedexLinkExtension(markdown.Extension):
|
||||||
u"""Markdown extension that translates the syntax used in effect text:
|
u"""Markdown extension that translates the syntax used in effect text:
|
||||||
|
|
||||||
|
|
6
setup.py
6
setup.py
|
@ -11,7 +11,7 @@ setup(
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'SQLAlchemy>=1.0,<1.4',
|
'SQLAlchemy>=1.0,<1.4',
|
||||||
'whoosh>=2.5,<2.7',
|
'whoosh>=2.5,<2.7',
|
||||||
'markdown==2.4.1',
|
'markdown>=2.4.1,<=2.6.11',
|
||||||
'construct==2.5.3',
|
'construct==2.5.3',
|
||||||
'six>=1.9.0',
|
'six>=1.9.0',
|
||||||
],
|
],
|
||||||
|
@ -22,8 +22,10 @@ setup(
|
||||||
},
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Programming Language :: Python :: 2.7",
|
"Programming Language :: Python :: 2.7",
|
||||||
"Programming Language :: Python :: 3.4",
|
|
||||||
"Programming Language :: Python :: 3.5",
|
"Programming Language :: Python :: 3.5",
|
||||||
|
"Programming Language :: Python :: 3.6",
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.7",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue