forked from witten/novel-stats
Compare commits
12 Commits
deroshkin_
...
master
Author | SHA1 | Date |
---|---|---|
Dan Helfman | aedc583fe8 | |
Dan Helfman | c53460bef0 | |
Dan Helfman | e4df1240fb | |
Dan Helfman | 3640f94625 | |
Dan Helfman | 6ea2b18d47 | |
Dan Helfman | 70b88e1671 | |
Dan Helfman | ec886a94bb | |
Dan Helfman | 5a0bde193f | |
Dan Helfman | bd875013b2 | |
Dan Helfman | c8651856a0 | |
Dan Helfman | 6d99b896c9 | |
Dan Helfman | 7ee1c7c439 |
31
.drone.yml
31
.drone.yml
|
@ -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
|
||||||
|
|
18
README.md
18
README.md
|
@ -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:
|
||||||
|
|
|
@ -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):
|
||||||
|
|
11
setup.py
11
setup.py
|
@ -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',
|
||||||
)
|
)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
17
tox.ini
|
@ -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 .
|
||||||
|
|
Loading…
Reference in New Issue