Skip to content

Commit 89b67f7

Browse files
author
Gerit Wagner
committed
initial commit
0 parents  commit 89b67f7

File tree

10 files changed

+211
-0
lines changed

10 files changed

+211
-0
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish to PyPI.org
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: [published]
6+
jobs:
7+
pypi:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
- name: Install poetry
13+
run: pipx install poetry
14+
- name: Setup poetry
15+
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
16+
- name: Publish package
17+
run: poetry publish --build

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
search_query/__pycache__/*
2+
test/__pycache__/*

.pre-commit-config.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-docstring-first
8+
- id: check-json
9+
- id: check-yaml
10+
- id: debug-statements
11+
- id: name-tests-test
12+
- id: requirements-txt-fixer
13+
- repo: https://github.com/psf/black
14+
rev: 23.9.1
15+
hooks:
16+
- id: black
17+
language_version: python3
18+
- repo: https://github.com/PyCQA/flake8
19+
rev: 6.1.0
20+
hooks:
21+
- id: flake8
22+
additional_dependencies: [flake8-typing-imports==1.12.0]
23+
args: ['--max-line-length=110', '--extend-ignore=E203,TYP006']
24+
- repo: https://github.com/asottile/reorder-python-imports
25+
rev: v3.12.0
26+
hooks:
27+
- id: reorder-python-imports
28+
args: [--py3-plus]
29+
- repo: https://github.com/asottile/pyupgrade
30+
rev: v3.14.0
31+
hooks:
32+
- id: pyupgrade
33+
args: [--py36-plus, --keep-runtime-typing]
34+
- repo: https://github.com/pre-commit/mirrors-mypy
35+
rev: 'v1.5.1'
36+
hooks:
37+
- id: mypy
38+
args: [--disallow-untyped-defs, --disallow-incomplete-defs, --disallow-untyped-calls]
39+
- repo: https://github.com/astral-sh/ruff-pre-commit
40+
rev: v0.0.292
41+
hooks:
42+
- id: ruff # runs faster than pylint
43+
args: [--fix, --exit-non-zero-on-fix]
44+
- repo: local
45+
hooks:
46+
- id: pytest-check
47+
name: pytest-check
48+
entry: pytest
49+
language: system
50+
pass_filenames: false
51+
always_run: true
52+
args:
53+
["--disable-warnings"]
54+
- repo: local # pylint should mostly be covered by ruff. Once custom checkers are supported (.pylintrc), we will switch to ruff completely.
55+
hooks:
56+
- id: pylint
57+
name: pylint
58+
entry: pylint
59+
language: system
60+
types: [python]
61+
files: search_query
62+
args:
63+
[
64+
"-rn", # Only display messages
65+
"-sn", # Don't display the score
66+
]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021, Gerit Wagner
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Search query
2+
3+
A python package for literature search queries.
4+
5+
6+
To use the queries, run:
7+
8+
```
9+
import search_query.query
10+
11+
query = search_query.query.Query()
12+
13+
```

pyproject.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[tool.poetry]
2+
name = "search-query"
3+
version = "0.1.0"
4+
description = "Package for managing literature search queries."
5+
authors = ["Katharina Ernst <katharina-maria.ernst@stud.uni-bamberg.de>", "Gerit Wagner <gerit.wagner@uni-bamberg.de>"]
6+
license = "MIT"
7+
readme = "README.md"
8+
packages = [{include = "search_query"}]
9+
include = ["LICENSE", "README.md"]
10+
11+
[tool.poetry.dependencies]
12+
python = "^3.8"
13+
14+
[tool.poetry.group.dev.dependencies]
15+
pytest = "^7.4.2"
16+
pylint = "^3.0.0"
17+
18+
[tool.mypy]
19+
python_version = 3.8
20+
warn_unused_configs = true
21+
ignore_missing_imports = true
22+
23+
[[tool.mypy.overrides]]
24+
module = [
25+
"requests.*",
26+
"yaml.*",
27+
"pkg_resources.*",
28+
]
29+
ignore_missing_imports = true
30+
31+
[build-system]
32+
requires = ["poetry-core"]
33+
build-backend = "poetry.core.masonry.api"

search_query/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Top-level package for SearchQuery."""
2+
3+
__author__ = """Gerit Wagner"""
4+
__email__ = "gerit.wagner@hec.ca"
5+
6+
from .__version__ import __version__
7+
8+
__all__ = ["__version__"]
9+
10+
# Instead of adding elements to __all__,
11+
# prefixing methods/variables with "__" is preferred.
12+
# Imports like "from x import *" are discouraged.

search_query/__version__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# pylint: disable=missing-module-docstring
2+
import pkg_resources
3+
4+
__version__ = pkg_resources.get_distribution("search_query").version

search_query/query.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
"""Query class."""
3+
from __future__ import annotations
4+
5+
6+
# class QueryTree:
7+
# ...
8+
9+
10+
class Query:
11+
query_tree = ""
12+
13+
def __init__(
14+
self,
15+
) -> None:
16+
pass
17+
18+
def parse(self, *, query_string) -> None:
19+
# ast library to create query_tree structure
20+
pass
21+
22+
def generate(self) -> str:
23+
# parameter: database/syntax?
24+
query_str = ""
25+
return query_str
26+
27+
def get_linked_list(self) -> dict:
28+
# generate linked_list from query_tree
29+
linked_list = {}
30+
return linked_list

test/test_query.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
"""Tests for the Query"""
3+
import search_query.query
4+
5+
6+
def test_parse() -> None:
7+
query = search_query.query.Query()
8+
query.parse(query_string="(digital OR online) AND work")
9+
10+
actual_list = query.get_linked_list()
11+
12+
expected_list = {1: "digital", 2: "online", 3: "1 OR 2", 4: "work", 5: "3 AND 4"}
13+
assert actual_list == expected_list

0 commit comments

Comments
 (0)