Skip to content

Commit 049b02c

Browse files
committed
style: format code with black
1 parent 74184db commit 049b02c

10 files changed

Lines changed: 295 additions & 177 deletions

File tree

document_placeholder/cli.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import sys
77
from pathlib import Path
88

9-
import document_placeholder.functions.date # noqa: F401 — register functions
10-
import document_placeholder.functions.logic # noqa: F401
11-
import document_placeholder.functions.math # noqa: F401
9+
import document_placeholder.functions.date # noqa: F401 — register functions
10+
import document_placeholder.functions.logic # noqa: F401
11+
import document_placeholder.functions.math # noqa: F401
1212
import document_placeholder.functions.string # noqa: F401
1313
import document_placeholder.functions.sql as sql_mod
1414
from document_placeholder.config import Config
@@ -23,23 +23,32 @@ def main() -> None:
2323
description="DocumentPlaceholder — fill Word templates using YAML configs",
2424
)
2525
parser.add_argument(
26-
"-c", "--config", default="template.yaml",
26+
"-c",
27+
"--config",
28+
default="template.yaml",
2729
help="YAML config path (default: template.yaml)",
2830
)
2931
parser.add_argument(
30-
"-t", "--template", default="template.docx",
32+
"-t",
33+
"--template",
34+
default="template.docx",
3135
help="Word template path (default: template.docx)",
3236
)
3337
parser.add_argument(
34-
"-o", "--output", default="output.docx",
38+
"-o",
39+
"--output",
40+
default="output.docx",
3541
help="Output file path (default: output.docx)",
3642
)
3743
parser.add_argument(
38-
"--db", default="data.db",
44+
"--db",
45+
default="data.db",
3946
help="SQLite database path (default: data.db)",
4047
)
4148
parser.add_argument(
42-
"-V", "--version", action="version",
49+
"-V",
50+
"--version",
51+
action="version",
4352
version=f"%(prog)s {__import__('document_placeholder').__version__}",
4453
)
4554
args = parser.parse_args()

document_placeholder/evaluator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ def evaluate_value(self, value: Any) -> Any:
114114
# -- output name resolution -----------------------------------------------
115115

116116
def resolve_output_name(
117-
self, raw_name: str, values: dict[str, object],
117+
self,
118+
raw_name: str,
119+
values: dict[str, object],
118120
) -> str:
119121
"""Resolve ``OUTPUT_NAME``: substitute ``{KEY}`` placeholders, then
120122
evaluate any remaining ``{expression}`` patterns."""
@@ -123,7 +125,8 @@ def resolve_output_name(
123125
placeholder = "{" + key + "}"
124126
if placeholder in result:
125127
result = result.replace(
126-
placeholder, str(value) if value is not None else "")
128+
placeholder, str(value) if value is not None else ""
129+
)
127130
# Only evaluate remaining {expr} patterns — never parse the whole
128131
# string as a single expression (it may contain literal dashes, etc.)
129132
if "{" in result:

document_placeholder/functions/math.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ def format_num(n, decimals=2) -> str:
9696
def random_int(low, high) -> int:
9797
"""Return a random integer in [*low*, *high*]."""
9898
import random
99+
99100
return random.randint(int(low), int(high))

document_placeholder/functions/string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def left(text, n) -> str:
8080
@_reg("RIGHT")
8181
def right(text, n) -> str:
8282
"""Return the last *n* characters."""
83-
return str(text)[-int(n):]
83+
return str(text)[-int(n) :]
8484

8585

8686
@_reg("PAD_LEFT")

0 commit comments

Comments
 (0)