Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
nandac authored Jul 3, 2023
2 parents 1411a40 + 5e3359e commit 2e5b7ed
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 156 deletions.
43 changes: 23 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -40,10 +40,10 @@ jobs:
run: |
poetry run pip install --upgrade pip
poetry install
- name: Install supported pandoc 2.19
- name: Install supported pandoc 3.14
run: |
wget https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb
sudo dpkg -i pandoc-2.19.2-1-amd64.deb
wget https://github.com/jgm/pandoc/releases/download/3.1.4/pandoc-3.1.4-1-amd64.deb
sudo dpkg -i pandoc-3.1.4-1-amd64.deb
- name: Install unsupported pandoc 2.10
run: |
wget https://github.com/jgm/pandoc/releases/download/2.10.1/pandoc-2.10.1-linux-amd64.tar.gz
Expand All @@ -63,51 +63,54 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Validate links in Markdown files
uses: JustinBeckwith/linkinator-action@v1
with:
retry: true

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: "3.9"

- name: Set Poetry cache
uses: actions/cache@v2
id: poetry-cache
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip

- name: Install Poetry
run: python -m pip install poetry

- name: Install dependencies
run: |
poetry run pip install --upgrade pip
poetry install
- name: Run linters
run: poetry run invoke lint
run: poetry install --no-interaction

- name: Run linters
run: poetry run invoke lint --diff

deploy:
name: Deploy
needs: [test, lint]
runs-on: ubuntu-latest
if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }}
if: github.ref=='refs/heads/main' && github.event_name!='pull_request'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: "3.9"

- name: Check release
id: check_release
run: |
python -m pip install --upgrade pip
python -m pip install poetry githubrelease httpx==0.16.1 autopub
echo "##[set-output name=release;]$(autopub check)"
python -m pip install poetry githubrelease httpx==0.18.2 autopub
echo "release=$(autopub check)" >> $GITHUB_OUTPUT
- name: Publish
if: ${{ steps.check_release.outputs.release=='' }}
env:
Expand Down
17 changes: 16 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
ci:
autoupdate_schedule: quarterly

# See https://pre-commit.com/hooks.html for info on hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -7,6 +10,7 @@ repos:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
Expand All @@ -26,9 +30,20 @@ repos:
hooks:
- id: flake8
args: [--max-line-length=88]
language_version: python3

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.8.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/hakancelikdev/unimport
rev: 0.16.0
hooks:
- id: unimport
args: [--remove, --include-star-import]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pandoc Reader: A Plugin for Pelican
===================================

[![Build Status](https://img.shields.io/github/workflow/status/pelican-plugins/pandoc-reader/build)](https://github.com/pelican-plugins/pandoc-reader/actions)
[![Build Status](https://img.shields.io/github/actions/workflow/status/pelican-plugins/pandoc-reader/main.yml?branch=main)](https://github.com/pelican-plugins/pandoc-reader/actions)
[![PyPI Version](https://img.shields.io/pypi/v/pelican-pandoc-reader)](https://pypi.org/project/pelican-pandoc-reader/)
![License](https://img.shields.io/pypi/l/pelican-pandoc-reader?color=blue)

Expand Down
28 changes: 11 additions & 17 deletions pelican/plugins/pandoc_reader/pandoc_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _create_html(self, source_path, content, pandoc_executable):
# Find and add bibliography if citations are specified
if citations:
for bib_file in self._find_bibs(source_path):
pandoc_cmd.append("--bibliography={0}".format(bib_file))
pandoc_cmd.append(f"--bibliography={bib_file}")

# Create HTML content using pandoc-reader-default.html template
output = self._run_pandoc(pandoc_cmd, content)
Expand Down Expand Up @@ -166,7 +166,7 @@ def _check_defaults(self, defaults_files):
# Get the data in all defaults files as a string
defaults_data = ""
for defaults_file in defaults_files:
with open(defaults_file, "r") as file_handle:
with open(defaults_file) as file_handle:
for line in file_handle.readlines():
defaults_data += line

Expand Down Expand Up @@ -216,7 +216,7 @@ def _calculate_reading_time(self, content):
reading_time = math.ceil(float(wordcount) / float(reading_speed))
if reading_time == 1:
time_unit = "minute"
reading_time = "{} {}".format(str(reading_time), time_unit)
reading_time = f"{str(reading_time)} {time_unit}"
except ValueError as words_per_minute_nan:
raise ValueError(
"READING_SPEED setting must be a number."
Expand Down Expand Up @@ -307,7 +307,7 @@ def _construct_pandoc_command(
pandoc_cmd.extend(arguments)
else:
for defaults_file in defaults_files:
pandoc_cmd.append("--defaults={0}".format(defaults_file))
pandoc_cmd.append(f"--defaults={defaults_file}")
return pandoc_cmd

@staticmethod
Expand Down Expand Up @@ -398,15 +398,15 @@ def _check_arguments(arguments):
"""Check to see that only supported arguments have been passed."""
for arg in arguments:
if arg in UNSUPPORTED_ARGUMENTS:
raise ValueError("Argument {0} is not supported.".format(arg))
raise ValueError(f"Argument {arg} is not supported.")

@staticmethod
def _check_if_unsupported_settings(defaults):
"""Check if unsupported settings are specified in the defaults."""
for arg in UNSUPPORTED_ARGUMENTS:
arg = arg[2:]
if defaults.get(arg, ""):
raise ValueError("The default {} should be set to false.".format(arg))
raise ValueError(f"The default {arg} should be set to false.")

@staticmethod
def _check_input_format(defaults):
Expand All @@ -422,10 +422,8 @@ def _check_input_format(defaults):
# Case where both reader and from are specified which is not supported
if reader_input and from_input:
raise ValueError(
(
"Specifying both from and reader is not supported."
" Please specify just one."
)
"Specifying both from and reader is not supported."
" Please specify just one."
)

if reader_input or from_input:
Expand All @@ -450,10 +448,8 @@ def _check_output_format(defaults):
# Case where both writer and to are specified which is not supported
if writer_output and to_output:
raise ValueError(
(
"Specifying both to and writer is not supported."
" Please specify just one."
)
"Specifying both to and writer is not supported."
" Please specify just one."
)

# Case where neither writer nor to value is set to html
Expand All @@ -462,9 +458,7 @@ def _check_output_format(defaults):
and to_output not in VALID_OUTPUT_FORMATS
):
output_formats = " or ".join(VALID_OUTPUT_FORMATS)
raise ValueError(
"Output format type must be either {}.".format(output_formats)
)
raise ValueError(f"Output format type must be either {output_formats}.")


def add_reader(readers):
Expand Down
Loading

0 comments on commit 2e5b7ed

Please sign in to comment.