Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 #2

Merged
merged 15 commits into from
Mar 7, 2022
Merged

V1 #2

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .devcontainer/Dockerfile

This file was deleted.

70 changes: 0 additions & 70 deletions .devcontainer/devcontainer.json

This file was deleted.

3 changes: 0 additions & 3 deletions .devcontainer/requirements.txt

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# .github/workflows/app.yaml
name: PyTest
on: push

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Check out repository code
uses: actions/checkout@v2

# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install pipenv
run: |
python -m pip install --upgrade pipenv wheel
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}

- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
pipenv install --deploy --dev
- name: Run test suite
run: |
pipenv run test -v
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ cython_debug/


# My Files
data/
.devcontainer/.env
.vscode
.vscode
build/
55 changes: 55 additions & 0 deletions BibTexTools/CLI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import click
from BibTexTools.parser import Parser
from BibTexTools.cleaner import Cleaner


@click.group()
def cli():
pass


@cli.command()
@click.argument("input", type=click.Path(exists=True))
@click.option("--keep_keys", "-k", is_flag=True, help="Keep original keys")
@click.option(
"--keep_unknown", "-u", is_flag=True, help="Keep enties that can not be cleaned"
)
@click.argument("output", type=click.File("w"))
def clean(input, keep_keys, keep_unknown, output):
"""Clean a BibTex bibliography"""
# parse
parser_obj = Parser()
bib = parser_obj.from_file(input)

# process
click.echo(
"Requesting citation metadata for {num_publications} publications, this may take a while..."
)
cleaner_obj = Cleaner(keep_keys=keep_keys, keep_unknown=keep_unknown)
processed_bib = cleaner_obj.clean(bib)

# write
bibtex_str = processed_bib.to_bibtex()
output.write(bibtex_str)


@cli.command()
@click.argument("input", type=click.Path(exists=True))
@click.option("--middle_names", "-m", is_flag=True, help="Include the middle names")
@click.argument("output", type=click.File("w"))
def abbreviate_authors(input, middle_names, output):
"""Abbreviate the author names of a BibTex bibliography"""
# parse
parser_obj = Parser()
bib = parser_obj.from_file(input)

# process
processed_bib = bib.abbreviate_names(middle_names)

# write
bibtex_str = processed_bib.to_bibtex()
output.write(bibtex_str)


cli.add_command(clean)
cli.add_command(abbreviate_authors)
File renamed without changes.
Loading