Skip to content

Commit 3531bec

Browse files
committed
Fix logger script generation
1 parent deeeef3 commit 3531bec

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

docs/source/changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ Glossary
3131
----------------------
3232
Releases
3333
----------------------
34-
34+
v2.6.1
35+
========
36+
- Fixed logger not being converted properly when exporting GUI data into a script.
3537

3638
v2.6.0
3739
==========

src/daf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
from .misc import *
1818

1919

20-
VERSION = "v2.6.0"
20+
VERSION = "2.6.1"

src/daf_gui/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def convert_objects_to_script(object: ObjectInfo | list | tuple | set | str):
183183
else:
184184
object_data.append(str(object))
185185

186-
return ",".join(object_data), import_data, "\n".join(other_data)
186+
return ",".join(object_data).strip(), import_data, "\n".join(other_data).strip()
187187

188188

189189
def convert_to_object_info(object_: object):

src/daf_gui/main.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"""
3737

3838
GITHUB_URL = "https://github.com/davidhozic/discord-advertisement-framework"
39-
DOC_URL = f"https://daf.davidhozic.com/en/{daf.VERSION}"
39+
DOC_URL = f"https://daf.davidhozic.com/en/v{daf.VERSION}"
4040

4141

4242
class Application():
@@ -428,6 +428,12 @@ def generate_daf_script(self):
428428
if other_str != "":
429429
other_str = "\n" + other_str
430430

431+
if logger_is_present:
432+
logger_str, logger_imports, _ = convert_objects_to_script(logger)
433+
logger_imports = "\n".join(set(logger_imports))
434+
else:
435+
logger_imports = ""
436+
431437
_ret = f'''
432438
"""
433439
Automatically generated file for Discord Advertisement Framework {daf.VERSION}.
@@ -440,19 +446,17 @@ def generate_daf_script(self):
440446
"""
441447
442448
# Import the necessary items
443-
{f"from {logger.class_.__module__} import {logger.class_.__name__}" if logger_is_present else ""}
444-
{f"from {tracing.__module__} import {tracing.__class__.__name__}" if tracing_is_present else ""}
449+
{logger_imports}
445450
{imports}
446-
451+
{f"from {tracing.__module__} import {tracing.__class__.__name__}" if tracing_is_present else ""}
447452
import daf{other_str}
448453
449454
# Define the logger
450-
{f"logger = {logger}" if logger_is_present else ""}
455+
{f"logger = {logger_str}" if logger_is_present else ""}
451456
452457
# Defined accounts
453458
accounts = {accounts_str}
454459
455-
456460
# Run the framework (blocking)
457461
daf.run(
458462
accounts=accounts,{run_logger_str}{run_tracing_str}

0 commit comments

Comments
 (0)