Compare commits

...

12 Commits

Author SHA1 Message Date
Dan Helfman aedc583fe8 Try a newer version of Alpine.
continuous-integration/drone/push Build is passing Details
2023-10-23 19:23:52 -07:00
Dan Helfman c53460bef0 Attempt CI build without pinning pip/setuptools.
continuous-integration/drone/push Build is failing Details
2023-10-23 19:20:21 -07:00
Dan Helfman e4df1240fb Remove Python 3.7 from CI.
continuous-integration/drone/push Build is failing Details
2023-10-23 19:16:43 -07:00
Dan Helfman 3640f94625 Using tox 4 in CI.
continuous-integration/drone/push Build is failing Details
2023-10-23 19:14:59 -07:00
Dan Helfman 6ea2b18d47 Drop Python 3.7 support (end of lifed).
continuous-integration/drone/push Build is failing Details
2023-10-23 19:12:38 -07:00
Dan Helfman 70b88e1671 Upgrade test requirements. 2023-10-23 19:09:31 -07:00
Dan Helfman ec886a94bb Remove note about PATH that's less relevant now that pipx is the install method.
continuous-integration/drone/push Build is failing Details
2023-10-21 19:29:05 -07:00
Dan Helfman 5a0bde193f Switch to pipx instead of pip in README.
continuous-integration/drone/push Build is failing Details
2023-10-20 14:36:38 -07:00
Dan Helfman bd875013b2 Fix formatting.
continuous-integration/drone/push Build is passing Details
2022-01-10 11:49:05 -08:00
Dan Helfman c8651856a0 Account for a few more edge cases.
continuous-integration/drone/push Build is failing Details
2022-01-10 09:59:18 -08:00
Dan Helfman 6d99b896c9 Drop support for Python 3.6 (end-of-lifed). Add support for Python 3.10.
continuous-integration/drone/push Build is passing Details
2022-01-09 21:56:13 -08:00
Dan Helfman 7ee1c7c439 Argument parsing' (#2)
continuous-integration/drone/push Build is passing Details
Reviewed-on: witten/novel-stats#2
2021-10-23 15:55:39 +00:00
8 changed files with 52 additions and 78 deletions

View File

@ -1,39 +1,12 @@
---
kind: pipeline kind: pipeline
name: python-3-6-alpine-3-9 name: python-3-11-alpine-3-18
clone: clone:
skip_verify: true skip_verify: true
steps: steps:
- name: build - name: build
image: alpine:3.9 image: alpine:3.18
pull: always
commands:
- tests/run-ci-tests
---
kind: pipeline
name: python-3-7-alpine-3-10
clone:
skip_verify: true
steps:
- name: build
image: alpine:3.10
pull: always
commands:
- tests/run-ci-tests
---
kind: pipeline
name: python-3-8-alpine-3-13
clone:
skip_verify: true
steps:
- name: build
image: alpine:3.13
pull: always pull: always
commands: commands:
- tests/run-ci-tests - tests/run-ci-tests

View File

@ -57,11 +57,11 @@ total: 946 words
## Installation ## Installation
Start by cloning the project with git. Then install it with Python's `pip`. Start by cloning the project with git. Then install it with
Example: [pipx](https://pypa.github.io/pipx/). Example:
```bash ```bash
pip3 install /path/to/novel-stats pipx install /path/to/novel-stats
``` ```
## Usage ## Usage
@ -226,17 +226,9 @@ make sure your changes work.
```bash ```bash
cd novel-stats/ cd novel-stats/
pip3 install --editable --user . pipx install --editable .
``` ```
Note that this will typically install the novel-stats commands into
`~/.local/bin`, which may or may not be on your PATH. There are other ways to
install novel-stats editable as well, for instance into the system Python
install (so without `--user`, as root), or even into a
[virtualenv](https://virtualenv.pypa.io/en/stable/). How or where you install
novel-stats is up to you, but generally an editable install makes development
and testing easier.
### Automated tests ### Automated tests
@ -245,7 +237,7 @@ you're in the `novel-stats/` working copy, install tox, which is used for
setting up testing environments: setting up testing environments:
```bash ```bash
pip3 install --user tox pipx install tox
``` ```
Finally, to actually run tests, run: Finally, to actually run tests, run:

View File

@ -72,7 +72,7 @@ def main():
word_count_by_chapter = collections.defaultdict(int) word_count_by_chapter = collections.defaultdict(int)
word_count_by_status = collections.defaultdict(int) word_count_by_status = collections.defaultdict(int)
word_count_by_act = collections.defaultdict(int) word_count_by_act = collections.defaultdict(int)
status_by_chapter = {} status_by_chapter = collections.defaultdict(lambda: collections.defaultdict(int))
current_status = None current_status = None
for line in mdfile.readlines(): for line in mdfile.readlines():
@ -83,15 +83,17 @@ def main():
chapter_heading = line[len(CHAPTER_MARKER) :].strip('()\n') chapter_heading = line[len(CHAPTER_MARKER) :].strip('()\n')
# Count the words in chapter heading, because the chapter number and title count as words. # Count the words in chapter heading, because the chapter number and title count as words.
if chapter_heading:
word_count_by_chapter[chapter_heading] = count_words(chapter_heading) word_count_by_chapter[chapter_heading] = count_words(chapter_heading)
status_by_chapter[chapter_heading] = collections.defaultdict(int)
current_status = None current_status = None
# Modified to allow multiple statuses in a single chapter, can swap back and forth. # Modified to allow multiple statuses in a single chapter, can swap back and forth.
elif line.startswith(STATUS_MARKER): elif line.startswith(STATUS_MARKER):
if current_status is None: if current_status is None:
current_status = line[len(STATUS_MARKER) :].strip('()\n') current_status = line[len(STATUS_MARKER) :].strip('()\n')
status_by_chapter[chapter_heading][current_status] = count_words(chapter_heading) if chapter_heading:
status_by_chapter[chapter_heading][current_status] = count_words(
chapter_heading
)
else: else:
current_status = line[len(STATUS_MARKER) :].strip('()\n') current_status = line[len(STATUS_MARKER) :].strip('()\n')
elif line.startswith(ACT_MARKER): elif line.startswith(ACT_MARKER):

View File

@ -20,8 +20,15 @@ setup(
"Topic :: Text Processing :: Markup", "Topic :: Text Processing :: Markup",
], ],
packages=find_packages(exclude=["tests*"]), packages=find_packages(exclude=["tests*"]),
entry_points={"console_scripts": ["novel-stats = novel_stats.novel_stats:main",]}, entry_points={
"console_scripts": [
"novel-stats = novel_stats.novel_stats:main",
]
},
install_requires=(), install_requires=(),
extras_require={"multi_file": ["MarkdownPP"],}, extras_require={
"multi_file": ["MarkdownPP"],
},
include_package_data=True, include_package_data=True,
python_requires='>3.7.0',
) )

View File

@ -1,18 +1,18 @@
appdirs==1.4.4; python_version >= '3.8' appdirs==1.4.4
attrs==20.3.0; python_version >= '3.8' attrs==23.1.0
black==19.10b0; python_version >= '3.8' black==23.10.1
click==7.1.2; python_version >= '3.8' click==8.1.7
coverage==5.3 coverage==7.3.2
flake8==3.8.4 flake8==6.1.0
flexmock==0.10.4 flexmock==0.11.3
isort==5.9.1 isort==5.12.0
mccabe==0.6.1 mccabe==0.7.0
pluggy==0.13.1 pluggy==1.3.0
pathspec==0.8.1; python_version >= '3.8' pathspec==0.11.2
py==1.10.0 py==1.11.0
pycodestyle==2.6.0 pycodestyle==2.11.1
pyflakes==2.2.0 pyflakes==3.1.0
pytest==6.1.2 pytest==7.4.2
pytest-cov==2.10.1 pytest-cov==4.1.0
regex; python_version >= '3.8' regex
typed-ast==1.4.2; python_version >= '3.8' typed-ast

0
tests/__init__.py Normal file
View File

View File

@ -9,7 +9,6 @@ set -e
apk add --no-cache python3 py3-pip apk add --no-cache python3 py3-pip
# If certain dependencies of black are available in this version of Alpine, install them. # If certain dependencies of black are available in this version of Alpine, install them.
apk add --no-cache py3-typed-ast py3-regex || true apk add --no-cache py3-typed-ast py3-regex || true
python3 -m pip install --upgrade pip==21.3.1 setuptools==58.2.0 pip3 install tox==4.11.3
pip3 install tox==3.24.4
export COVERAGE_FILE=/tmp/.coverage export COVERAGE_FILE=/tmp/.coverage
tox --workdir /tmp/.tox --sitepackages tox --workdir /tmp/.tox --sitepackages

17
tox.ini
View File

@ -1,16 +1,16 @@
[tox] [tox]
envlist = py36,py37,py38,py39 env_list = py38,py39,py310,py311
skip_missing_interpreters = True skip_missing_interpreters = True
skipsdist = True package = editable
minversion = 3.14.1 minversion = 4.0
[testenv] [testenv]
usedevelop = True deps =
deps = -rtest_requirements.txt -r test_requirements.txt
passenv = COVERAGE_FILE pass_env = COVERAGE_FILE
commands = commands =
pytest {posargs} pytest {posargs}
py38,py39: black --check . black --check .
isort --check-only --settings-path setup.cfg . isort --check-only --settings-path setup.cfg .
flake8 novel_stats tests flake8 novel_stats tests
@ -23,6 +23,7 @@ commands =
pytest {posargs} pytest {posargs}
[testenv:isort] [testenv:isort]
deps = {[testenv]deps} deps =
{[testenv]deps}
commands = commands =
isort --settings-path setup.cfg . isort --settings-path setup.cfg .