commit
0efbe23d89
|
@ -48,8 +48,7 @@ def log_operation(operation: str, filename: str) -> None:
|
||||||
if not os.path.exists(LOG_FILE_PATH):
|
if not os.path.exists(LOG_FILE_PATH):
|
||||||
with open(LOG_FILE_PATH, "w", encoding="utf-8") as f:
|
with open(LOG_FILE_PATH, "w", encoding="utf-8") as f:
|
||||||
f.write("File Operation Logger ")
|
f.write("File Operation Logger ")
|
||||||
|
append_to_file(str(LOG_FILE_PATH), log_entry, should_log=False)
|
||||||
append_to_file(str(LOG_FILE_PATH), log_entry, shouldLog=False)
|
|
||||||
|
|
||||||
|
|
||||||
def split_file(
|
def split_file(
|
||||||
|
@ -166,12 +165,13 @@ def write_to_file(filename: str, text: str) -> str:
|
||||||
@command(
|
@command(
|
||||||
"append_to_file", "Append to file", '"filename": "<filename>", "text": "<text>"'
|
"append_to_file", "Append to file", '"filename": "<filename>", "text": "<text>"'
|
||||||
)
|
)
|
||||||
def append_to_file(filename: str, text: str, shouldLog: bool = True) -> str:
|
def append_to_file(filename: str, text: str, should_log: bool = True) -> str:
|
||||||
"""Append text to a file
|
"""Append text to a file
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename (str): The name of the file to append to
|
filename (str): The name of the file to append to
|
||||||
text (str): The text to append to the file
|
text (str): The text to append to the file
|
||||||
|
should_log (bool): Should log output
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: A message indicating success or failure
|
str: A message indicating success or failure
|
||||||
|
@ -181,7 +181,7 @@ def append_to_file(filename: str, text: str, shouldLog: bool = True) -> str:
|
||||||
with open(filepath, "a") as f:
|
with open(filepath, "a") as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
if shouldLog:
|
if should_log:
|
||||||
log_operation("append", filename)
|
log_operation("append", filename)
|
||||||
|
|
||||||
return "Text appended successfully."
|
return "Text appended successfully."
|
||||||
|
|
Loading…
Reference in New Issue