Skip to content

Commit

Permalink
apply ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 committed Jun 20, 2024
1 parent 8b5cd64 commit 26ee209
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions commands/file_processing.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import click
from logs.logger import logger


@click.command()
@click.argument('file_path', type=click.Path(exists=True))
@click.argument('file_id', type=str)
@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
Expand All @@ -16,4 +17,4 @@ def pdf_xml(file_path, file_id):
"""

# Function Implementation
logger.info(f'Converted: {file_path} with ID: {file_id} to XML')
logger.info(f"Converted: {file_path} with ID: {file_id} to XML")
5 changes: 1 addition & 4 deletions logs/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import logging

logging.basicConfig(
level=logging.INFO,
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler()]
level=logging.INFO, format="%(message)s", datefmt="[%X]", handlers=[RichHandler()]
)

logger = logging.getLogger("rich")
6 changes: 4 additions & 2 deletions osm/cli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import click
from commands.file_processing import pdf_xml


@click.group()
def cli():
"""Main command group."""
pass


# Add commands to the main group
cli.add_command(pdf_xml)

if __name__ == '__main__':
cli()
if __name__ == "__main__":
cli()
11 changes: 6 additions & 5 deletions tests/test_file_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

from commands.file_processing import pdf_xml


@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')
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")

def teardown_method(self):
# Remove the temporary PDF file and any generated XML file
Expand All @@ -25,7 +26,7 @@ def test_pdf_xml_command(self, caplog):
caplog.set_level(logging.INFO)

runner = CliRunner()
result = runner.invoke(pdf_xml, [self.pdf_path, 'test_file'])
result = runner.invoke(pdf_xml, [self.pdf_path, "test_file"])

assert result.exit_code == 0
assert f'Converted: {self.pdf_path}' in caplog.text
assert f"Converted: {self.pdf_path}" in caplog.text

0 comments on commit 26ee209

Please sign in to comment.