Skip to content

Commit

Permalink
fix: enable_sourcing_from_file as factory
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwhalen committed Nov 4, 2024
1 parent 9849448 commit 244d2ec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lkj/filesys.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def enable_sourcing_from_file(func=None, *, write_output=False):
"""
Decorator for functions enables the decorated function to source from a file.
Is is to be applied to functions that take a string or bytes as their first
It is to be applied to functions that take a string or bytes as their first
argument. Decorating the function will enable it to detect if the first argument
is a file path, read the file content, call the function with the file content
as the first argument. Optionally, the decorated function can write the result
Expand All @@ -24,10 +24,10 @@ def enable_sourcing_from_file(func=None, *, write_output=False):
"""
if func is None:
return partial(process_file_if_path, write_output=write_output)
return partial(enable_sourcing_from_file, write_output=write_output)

@wraps(func)
def wrapper(*args, **kwargs):
def wrapper(*args, write_output=write_output, **kwargs):
# Check if the first argument is a string and a valid file path
if args and isinstance(args[0], str) and os.path.isfile(args[0]):
file_path = args[0]
Expand Down

0 comments on commit 244d2ec

Please sign in to comment.