-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
163 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# Ignore the virtual environment directory | ||
_version.py | ||
node_modules | ||
venv/ | ||
*coverage* | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 24.4.2 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: "v0.4.9" | ||
hooks: | ||
- id: ruff | ||
args: ["--fix"] | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
files: ".*\\.py" | ||
exclude: "examples|docs/examples" | ||
- id: check-added-large-files | ||
- id: check-toml | ||
- id: end-of-file-fixer | ||
exclude: "examples|docs/examples" | ||
|
||
# - repo: https://github.com/pre-commit/mirrors-prettier | ||
# rev: v4.0.0-alpha.8 | ||
# hooks: | ||
# - id: prettier | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
name: isort | ||
args: ["--profile", "black"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import _version | ||
|
||
__version__ = _version.version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import click | ||
|
||
from osm_cli.logging.logger import logger | ||
|
||
|
||
@click.group() | ||
def osm(): | ||
"""Main command for OSM""" | ||
pass | ||
|
||
|
||
@osm.command() | ||
@click.argument("file_path", type=click.Path(exists=True)) | ||
@click.argument("file_id", type=str) | ||
def pdf_xml(file_path, file_id): | ||
"""This function converts a file from PDF to XML""" | ||
# Function Implementation | ||
logger.info(f"Converted: {file_path} with ID: {file_id} to XML") |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from pydantic.v1 import BaseSettings | ||
|
||
|
||
class AppConfig(BaseSettings): | ||
PORT: int = 8082 | ||
HOST: str = "localhost" | ||
PROTOCAL: str = "http" | ||
|
||
|
||
config = AppConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
[project] | ||
name = "osm-cli" | ||
description = "Open Science Metrics (OSM) client for tracking scientific transparency and reproducibility metrics" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
keywords = [ | ||
"open science", | ||
"altmetrics", | ||
"scientific transparency", | ||
"reproducibility" | ||
] | ||
dynamic = ["version"] | ||
|
||
dependencies = [ | ||
"click>=8.1.7", | ||
"rich>=13.7.1", | ||
] | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"tox>=4.15.0", | ||
"pytest>=8.2.1", | ||
"pytest-cov", | ||
"ruff>=0.4.9", | ||
"build", | ||
"twine", | ||
"pre-commit", | ||
"pkginfo>=1.10" | ||
] | ||
|
||
[project.urls] | ||
homepage = "https://website" | ||
source = "https://github.com/nimh-dsst/osm-cli" | ||
issues = "https://github.com/nimh-dsst/osm-cli/issues" | ||
|
||
[build-system] | ||
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools_scm] | ||
write_to = "osm_cli/_version.py" | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["osm_cli"] | ||
|
||
[project.scripts] | ||
osm-cli = "osm_cli.cli.main:osm" | ||
|
||
[tool.black] | ||
line-length = 88 | ||
target-version = ["py38", "py39", "py310"] | ||
|
||
[tool.ruff] | ||
line-length = 88 | ||
indent-width = 4 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,22 @@ | ||
import pytest | ||
from click.testing import CliRunner | ||
import os | ||
import logging | ||
|
||
from commands.file_processing import pdf_xml | ||
|
||
import pytest | ||
from click.testing import CliRunner | ||
|
||
@pytest.mark.usefixtures("caplog") | ||
class TestFileProcessing: | ||
def setup_method(self): | ||
# Create a temporary PDF file for testing | ||
self.pdf_path = "test_sample.pdf" | ||
with open(self.pdf_path, "wb") as f: | ||
f.write(b"%PDF-1.4\n%Test PDF content\n") | ||
from osm_cli.cli.main import pdf_xml | ||
|
||
def teardown_method(self): | ||
# Remove the temporary PDF file and any generated XML file | ||
if os.path.exists(self.pdf_path): | ||
os.remove(self.pdf_path) | ||
xml_output = f"{self.pdf_path.replace('.pdf', '')}_test_file.xml" | ||
if os.path.exists(xml_output): | ||
os.remove(xml_output) | ||
|
||
def test_pdf_xml_command(self, caplog): | ||
caplog.set_level(logging.INFO) | ||
@pytest.fixture | ||
def sample_pdf(tmp_path): | ||
pdf_path = tmp_path / "test_sample.pdf" | ||
pdf_path.write_bytes(b"%PDF-1.4\n%Test PDF content\n") | ||
yield pdf_path | ||
pdf_path.unlink() | ||
|
||
runner = CliRunner() | ||
result = runner.invoke(pdf_xml, [self.pdf_path, "test_file"]) | ||
|
||
assert result.exit_code == 0 | ||
assert f"Converted: {self.pdf_path}" in caplog.text | ||
def test_pdf_converter(caplog, sample_pdf): | ||
caplog.set_level(logging.INFO) | ||
runner = CliRunner() | ||
result = runner.invoke(pdf_xml, [str(sample_pdf), "test_file"]) | ||
assert result.exit_code == 0 | ||
assert f"Converted: {sample_pdf}" in caplog.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters