Skip to content

Commit dbade97

Browse files
Initial commit
0 parents  commit dbade97

11 files changed

Lines changed: 675 additions & 0 deletions

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
*.sh eol=lf

.gitignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Distribution / packaging
7+
.Python
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
pip-wheel-metadata/
21+
share/python-wheels/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
MANIFEST
26+
27+
# Unit test / coverage reports
28+
htmlcov/
29+
.tox/
30+
.nox/
31+
.coverage
32+
.coverage.*
33+
.cache
34+
nosetests.xml
35+
coverage.xml
36+
*.cover
37+
*.py,cover
38+
.hypothesis/
39+
.pytest_cache/
40+
41+
# Django stuff:
42+
*.log
43+
local_settings.py
44+
db.sqlite3
45+
db.sqlite3-journal
46+
47+
# Flask stuff:
48+
instance/
49+
.webassets-cache
50+
51+
# Sphinx documentation
52+
docs/_build/
53+
54+
# Jupyter Notebook
55+
.ipynb_checkpoints
56+
57+
# IPython
58+
profile_default/
59+
ipython_config.py
60+
61+
# pyenv
62+
.python-version
63+
64+
# Celery stuff
65+
celerybeat-schedule
66+
celerybeat.pid
67+
68+
# Environments
69+
.env
70+
.venv
71+
env/
72+
venv/
73+
ENV/
74+
env.bak/
75+
venv.bak/
76+
77+
# mypy
78+
.mypy_cache/
79+
.dmypy.json
80+
dmypy.json

.pre-commit-config.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
default_stages: [commit]
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.3.0
5+
hooks:
6+
- id: check-executables-have-shebangs
7+
stages: [push]
8+
- id: check-merge-conflict
9+
- id: check-shebang-scripts-are-executable
10+
stages: [push]
11+
- id: check-toml
12+
stages: [push]
13+
- id: check-yaml
14+
stages: [push]
15+
- id: end-of-file-fixer
16+
stages: [push]
17+
- id: trailing-whitespace
18+
stages: [push]
19+
- repo: local
20+
hooks:
21+
- id: black
22+
name: Running black from local poetry env
23+
entry: poetry run black .
24+
# Black does not work with language as python
25+
language: system
26+
types:
27+
- python
28+
- id: flake8
29+
name: Running flake8 from local poetry env
30+
entry: poetry run flake8 .
31+
language: python
32+
files: ".*.py"
33+
- id: isort
34+
name: Running isort from local poetry env
35+
entry: poetry run isort .
36+
language: python
37+
files: ".*.py"

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) 2022 Gurashish Singh
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Placeholder Project Name
2+
3+
4+
## Initial setup
5+
The bash script **setup.sh** is an executable. Devs should run
6+
```bash
7+
chmod +x setup.sh
8+
```
9+
(Powershell may have different syntax to set executable permissions) before running
10+
```
11+
bash setup.sh
12+
```
13+
14+
The **pyproject.toml** file contains project dependencies and can be updated to add more dependencies at any stage of the project by running `poetry add <packagename>`.
15+
Minimum Python version supported is 3.9.
16+
17+
The **.pre-commit-config.yaml** contains all the linters that runs before committing changes.

logger.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from __future__ import annotations
2+
3+
import logging
4+
import logging.config
5+
6+
from yaml import safe_load
7+
8+
9+
def set_logging(config_file: str = "logging.yaml", log_level: int | str = logging.DEBUG) -> None:
10+
try:
11+
with open(config_file, "rt") as f:
12+
config = safe_load(f.read())
13+
logging.config.dictConfig(config)
14+
except Exception as err:
15+
print(f"Error occurred while creating logger from {config_file = }.\nERROR: {err}")
16+
print("Falling back to basic logging configuration")
17+
logging.basicConfig(level=log_level)

logging.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 1
2+
formatters:
3+
simple:
4+
format: "%(levelname)s: %(asctime)s %(message)s"
5+
datefmt: "%Y/%m/%d %I:%M:%S %p"
6+
json:
7+
(): "pythonjsonlogger.jsonlogger.JsonFormatter"
8+
format: "%(asctime)s %(levelname)s %(name)s %(module)s %(funcName)s %(message)s"
9+
datefmt: "%Y/%m/%d %I:%M:%S %p"
10+
handlers:
11+
console:
12+
class: logging.StreamHandler
13+
level: INFO
14+
formatter: simple
15+
stream: ext://sys.stdout
16+
file:
17+
class: logging.FileHandler
18+
level: DEBUG
19+
formatter: json
20+
filename: placeholder.log
21+
mode: w
22+
delay: True
23+
root:
24+
level: DEBUG
25+
handlers: [console]

0 commit comments

Comments
 (0)