Compare commits
No commits in common. "5693cf8f8a2192aded90119ef171e578a43bc236" and "73735b378f69857ec836024b06b533ac21817032" have entirely different histories.
5693cf8f8a
...
73735b378f
4 changed files with 31 additions and 41 deletions
|
@ -1,6 +1,27 @@
|
||||||
# Pre-commit hooks to run tests and ensure code is cleaned.
|
# Pre-commit hooks to run tests and ensure code is cleaned.
|
||||||
# See https://pre-commit.com for more information
|
# See https://pre-commit.com for more information
|
||||||
repos:
|
repos:
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: pytest
|
||||||
|
name: pytest
|
||||||
|
entry: python3 -m pytest tests
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
pass_filenames: false
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: pylint
|
||||||
|
name: pylint
|
||||||
|
entry: pylint --extension-pkg-whitelist=cx_Oracle
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
require_serial: true
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 6.0.0
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
args: ['--max-line-length=100']
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.3.1
|
rev: v3.3.1
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -16,30 +37,3 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
args: ['--profile', 'black', '--line-length', '100']
|
args: ['--profile', 'black', '--line-length', '100']
|
||||||
- repo: https://github.com/PyCQA/flake8
|
|
||||||
rev: 6.0.0
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
args: ['--max-line-length=100']
|
|
||||||
- repo: local
|
|
||||||
hooks:
|
|
||||||
- id: pylint
|
|
||||||
name: pylint
|
|
||||||
entry: pylint --extension-pkg-whitelist=cx_Oracle
|
|
||||||
language: system
|
|
||||||
types: [python]
|
|
||||||
require_serial: true
|
|
||||||
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
|
|
||||||
rev: v1.0.5
|
|
||||||
hooks:
|
|
||||||
- id: python-bandit-vulnerability-check
|
|
||||||
name: bandit
|
|
||||||
args: [--skip, "B101", --recursive, mylib]
|
|
||||||
- repo: local
|
|
||||||
hooks:
|
|
||||||
- id: pytest
|
|
||||||
name: pytest
|
|
||||||
entry: python3 -m pytest tests
|
|
||||||
language: system
|
|
||||||
types: [python]
|
|
||||||
pass_filenames: false
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ class DB:
|
||||||
def insert(self, table, values, just_try=False):
|
def insert(self, table, values, just_try=False):
|
||||||
"""Run INSERT SQL query"""
|
"""Run INSERT SQL query"""
|
||||||
# pylint: disable=consider-using-f-string
|
# pylint: disable=consider-using-f-string
|
||||||
sql = "INSERT INTO {} ({}) VALUES ({})".format( # nosec
|
sql = "INSERT INTO {} ({}) VALUES ({})".format(
|
||||||
self._quote_table_name(table),
|
self._quote_table_name(table),
|
||||||
", ".join([self._quote_field_name(field) for field in values.keys()]),
|
", ".join([self._quote_field_name(field) for field in values.keys()]),
|
||||||
", ".join([self.format_param(key) for key in values]),
|
", ".join([self.format_param(key) for key in values]),
|
||||||
|
@ -280,7 +280,7 @@ class DB:
|
||||||
def update(self, table, values, where_clauses, where_op=None, just_try=False):
|
def update(self, table, values, where_clauses, where_op=None, just_try=False):
|
||||||
"""Run UPDATE SQL query"""
|
"""Run UPDATE SQL query"""
|
||||||
# pylint: disable=consider-using-f-string
|
# pylint: disable=consider-using-f-string
|
||||||
sql = "UPDATE {} SET {}".format( # nosec
|
sql = "UPDATE {} SET {}".format(
|
||||||
self._quote_table_name(table),
|
self._quote_table_name(table),
|
||||||
", ".join(
|
", ".join(
|
||||||
[f"{self._quote_field_name(key)} = {self.format_param(key)}" for key in values]
|
[f"{self._quote_field_name(key)} = {self.format_param(key)}" for key in values]
|
||||||
|
@ -306,7 +306,7 @@ class DB:
|
||||||
|
|
||||||
def delete(self, table, where_clauses, where_op="AND", just_try=False):
|
def delete(self, table, where_clauses, where_op="AND", just_try=False):
|
||||||
"""Run DELETE SQL query"""
|
"""Run DELETE SQL query"""
|
||||||
sql = f"DELETE FROM {self._quote_table_name(table)}" # nosec
|
sql = f"DELETE FROM {self._quote_table_name(table)}"
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -327,7 +327,7 @@ class DB:
|
||||||
|
|
||||||
def truncate(self, table, just_try=False):
|
def truncate(self, table, just_try=False):
|
||||||
"""Run TRUNCATE SQL query"""
|
"""Run TRUNCATE SQL query"""
|
||||||
sql = f"TRUNCATE TABLE {self._quote_table_name(table)}" # nosec
|
sql = f"TRUNCATE TABLE {self._quote_table_name(table)}"
|
||||||
|
|
||||||
if just_try:
|
if just_try:
|
||||||
log.debug("Just-try mode: execute TRUNCATE query: %s", sql)
|
log.debug("Just-try mode: execute TRUNCATE query: %s", sql)
|
||||||
|
|
|
@ -173,9 +173,7 @@ class EmailClient(
|
||||||
self.templates[template_name] = {}
|
self.templates[template_name] = {}
|
||||||
log.debug("Load email template %s %s from %s", template_name, template_type, filepath)
|
log.debug("Load email template %s %s from %s", template_name, template_type, filepath)
|
||||||
with open(filepath, encoding="utf8") as file_desc:
|
with open(filepath, encoding="utf8") as file_desc:
|
||||||
self.templates[template_name][template_type] = MakoTemplate(
|
self.templates[template_name][template_type] = MakoTemplate(file_desc.read())
|
||||||
file_desc.read()
|
|
||||||
) # nosec
|
|
||||||
|
|
||||||
def forge_message(
|
def forge_message(
|
||||||
self,
|
self,
|
||||||
|
@ -577,14 +575,13 @@ if __name__ == "__main__":
|
||||||
text=(
|
text=(
|
||||||
"Just a test email sent at {sent_date}."
|
"Just a test email sent at {sent_date}."
|
||||||
if not options.test_mako
|
if not options.test_mako
|
||||||
else MakoTemplate("Just a test email sent at ${sent_date | h}.") # nosec
|
else MakoTemplate("Just a test email sent at ${sent_date}.")
|
||||||
),
|
),
|
||||||
html=(
|
html=(
|
||||||
"<strong>Just a test email.</strong> <small>(sent at {sent_date | h})</small>"
|
"<strong>Just a test email.</strong> <small>(sent at {sent_date})</small>"
|
||||||
if not options.test_mako
|
if not options.test_mako
|
||||||
else MakoTemplate( # nosec
|
else MakoTemplate(
|
||||||
"<strong>Just a test email.</strong> "
|
"<strong>Just a test email.</strong> <small>(sent at ${sent_date})</small>"
|
||||||
"<small>(sent at ${sent_date | h})</small>"
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -51,8 +51,7 @@ def main(argv=None): # pylint: disable=too-many-locals,too-many-statements
|
||||||
test_content = b"Juste un test."
|
test_content = b"Juste un test."
|
||||||
tmp_dir = tempfile.TemporaryDirectory() # pylint: disable=consider-using-with
|
tmp_dir = tempfile.TemporaryDirectory() # pylint: disable=consider-using-with
|
||||||
tmp_file = os.path.join(
|
tmp_file = os.path.join(
|
||||||
tmp_dir.name,
|
tmp_dir.name, f'tmp{"".join(random.choice(string.ascii_lowercase) for i in range(8))}'
|
||||||
f'tmp{"".join(random.choice(string.ascii_lowercase) for i in range(8))}', # nosec
|
|
||||||
)
|
)
|
||||||
log.debug('Temporary file path: "%s"', tmp_file)
|
log.debug('Temporary file path: "%s"', tmp_file)
|
||||||
with open(tmp_file, "wb") as file_desc:
|
with open(tmp_file, "wb") as file_desc:
|
||||||
|
|
Loading…
Reference in a new issue