Skip to content

Commit

Permalink
Rename module to python_app
Browse files Browse the repository at this point in the history
This is to make things work a bit better as a pdm template
  • Loading branch information
bsweger committed Jan 28, 2024
1 parent bc1a76b commit 7de53f8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = 'python-app-template'
description = 'Boilerplate for Python applications'
name = 'python-app'
description = 'PDM template for simple Python applications'
license = {text = 'MIT License'}
readme = 'README.md'
requires-python = '>=3.10'
Expand All @@ -26,18 +26,18 @@ dev = [
]

[project.entry-points.'console_scripts']
pythonapp = 'pythonapp.app:main'
python_app = 'python_app.app:main'

[build-system]
# Minimum requirements for the build system to execute.
requires = ['setuptools', 'wheel']

[tools.setuptools]
packages = ['pythonapp']
packages = ['python_app']

[tool.pythonapp]
[tool.python-app]
# to write json-formatted logs to disk, uncomment the following line specify the file location
log_file = '/Users/becky/logs/pythonapp.log'
# log_file = '/Users/becky/logs/python_app.log'

[tool.ruff]
line-length = 120
Expand All @@ -47,4 +47,4 @@ extend-select = ['I']
quote-style = 'single'

[tool.setuptools.dynamic]
version = {attr = 'pythonapp.__version__'}
version = {attr = 'python_app.__version__'}
File renamed without changes.
6 changes: 3 additions & 3 deletions src/pythonapp/app.py → src/python_app/python_app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging

from pythonapp.util.date import get_current_date
from pythonapp.util.logs import LoggerSetup
from python_app.util.date import get_current_date
from python_app.util.logs import LoggerSetup


def main():
"""Application entry point."""

LoggerSetup('pythonapp').init_logger()
LoggerSetup('python_app').init_logger()
logger = logging.getLogger(__name__)

logger.info('formatting the date')
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pythonapp/util/logs.py → src/python_app/util/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def init_logger(self):
# if app config specifies a log file, add a handler for it and
# format the log entries as JSON
config = toml.load(self.config_file)
log_file = config.get('tool', {}).get('pythonapp', {}).get('log_file')
log_file = config.get('tool', {}).get('python_app', {}).get('log_file')
if log_file:
log_path = self.create_log_file(log_file)
handler = logging.FileHandler(log_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Unit tests for the date module."""

from freezegun import freeze_time
from pythonapp.util.date import get_current_date
from python_app.util.date import get_current_date


@freeze_time('2024-01-02')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest
import toml
from pythonapp.util.logs import LoggerSetup
from python_app.util.logs import LoggerSetup


@pytest.fixture()
Expand All @@ -28,7 +28,7 @@ def app_config_with_logfile(tmp_path):

# create an app config that specifies a log file
with open(str(app_config_file), 'w') as f:
toml.dump({'tool': {'pythonapp': {'log_file': str(app_log_file)}}}, f)
toml.dump({'tool': {'python_app': {'log_file': str(app_log_file)}}}, f)

return app_config_file, app_log_file

Expand Down

0 comments on commit 7de53f8

Please sign in to comment.