Skip to content

Commit e4d0d7c

Browse files
Merge pull request #3 from matthew-on-git/pre_commit
feat: linting and pre-commit
2 parents 72599a7 + 853c40c commit e4d0d7c

File tree

8 files changed

+544
-369
lines changed

8 files changed

+544
-369
lines changed

.github/workflows/pylint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.8", "3.9", "3.10"]
10+
python-version: ["3.9", "3.10"]
1111
steps:
1212
- uses: actions/checkout@v4
1313
- name: Set up Python ${{ matrix.python-version }}
@@ -17,6 +17,7 @@ jobs:
1717
- name: Install dependencies
1818
run: |
1919
python -m pip install --upgrade pip
20+
pip install -r requirements.txt
2021
pip install pylint
2122
- name: Analysing the code with pylint
2223
run: |

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: https://github.com/matthew-on-git/pre-commit-conventional-commits.git
3+
rev: 747218c92008b8af09f278a11bcffb6d3d34a20f
4+
hooks:
5+
-
6+
id: conventional-commit-check
7+
stages:
8+
- commit-msg

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,31 @@ Mutually exclusive options (one required):
6060
#### Export Non-Secured Variables
6161
To export non-secured variables from the "development" environment to `variables.json`:
6262
```
63-
./manage-bitbucket-env.py -w your_workspace -r your_repo -d development -o variables.json
63+
./manage_bitbucket_env.py -w your_workspace -r your_repo -d development -o variables.json
6464
```
6565

6666
#### Export All Variables
6767
To export all variables from the "development" environment to `all_variables.json`:
6868
```
69-
./manage-bitbucket-env.py -w your_workspace -r your_repo -d development -a all_variables.json
69+
./manage_bitbucket_env.py -w your_workspace -r your_repo -d development -a all_variables.json
7070
```
7171

7272
#### Export Secured Variable Keys
7373
To export the keys of secured variables from the "development" environment to `secret_keys.json`:
7474
```
75-
./manage-bitbucket-env.py -w your_workspace -r your_repo -d development -e secret_keys.json
75+
./manage_bitbucket_env.py -w your_workspace -r your_repo -d development -e secret_keys.json
7676
```
7777

7878
#### Import Non-Secured Variables
7979
To import non-secured variables from `variables.json` to the "development" environment:
8080
```
81-
./manage-bitbucket-env.py -w your_workspace -r your_repo -d development -i variables.json
81+
./manage_bitbucket_env.py -w your_workspace -r your_repo -d development -i variables.json
8282
```
8383

8484
#### Import All Variables
8585
To import all variables from `all_variables.json` to the "development" environment:
8686
```
87-
./manage-bitbucket-env.py -w your_workspace -r your_repo -d development --import-all all_variables.json
87+
./manage_bitbucket_env.py -w your_workspace -r your_repo -d development --import-all all_variables.json
8888
```
8989

9090
## JSON File Formats

helpers/bitbucket_logging.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Logging module for Bitbucket environment manager.
4+
5+
This module provides a custom Logger class that extends the standard logging.Logger
6+
to provide colored console output and optional file logging capabilities.
7+
"""
8+
9+
# pylint: disable=too-many-arguments, too-many-positional-arguments
10+
11+
import datetime
12+
import inspect
13+
import logging
14+
import os
15+
16+
import coloredlogs # type: ignore
17+
18+
19+
class BitbucketLogger(logging.Logger):
20+
"""Build Logger"""
21+
def __init__(
22+
self,
23+
enable_log_file: bool = False,
24+
log_level: str = 'INFO'
25+
):
26+
super().__init__(os.path.basename(inspect.stack()[1].filename))
27+
self.log_name: str = os.path.basename(inspect.stack()[1].filename)
28+
self.log_level: str = log_level
29+
self.enable_log_file: bool = enable_log_file
30+
31+
def _setup_logging(self) -> logging.Logger:
32+
"""Create and configure the logger instance."""
33+
datestamp = datetime.datetime.today().strftime("%m-%d-%Y")
34+
logger = logging.getLogger(self.log_name)
35+
logging.captureWarnings(True)
36+
coloredlogs.install(level=self.log_level) # type: ignore
37+
if self.enable_log_file:
38+
formatter = logging.Formatter(
39+
fmt=("[%(asctime)s] - [%(levelname)s] - "
40+
"[%(name)s.%(funcName)s:%(lineno)d] - [%(message)s]")
41+
)
42+
file_handler = logging.FileHandler(
43+
filename=f"{self.log_name}-{datestamp}.log",
44+
mode="a"
45+
)
46+
file_handler.setFormatter(formatter)
47+
logger.addHandler(file_handler)
48+
49+
return logger
50+
51+
def create_logger(self) -> logging.Logger:
52+
"""Create and return a configured logger instance."""
53+
return self._setup_logging()
54+
55+
def get_log_name(self) -> str:
56+
"""Get the log name."""
57+
return self.log_name

helpers/logging.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)