Skip to content

Commit

Permalink
feat: add write_to_file as an attribute of written_key for easier access
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwhalen committed Jan 17, 2025
1 parent ac7ae84 commit 16158c0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dol/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,9 +1909,9 @@ def written_key(
If None, a temporary file is created.
If a string starting with '*', the '*' is replaced with a unique temporary filename.
If a string that has a '*' somewhere in the middle, what's on the left of if is used as a directory
and the '*' is replaced with a unique temporary filename. For example
and the '*' is replaced with a unique temporary filename. For example
'/tmp/*_file.ext' would be replaced with '/tmp/oiu8fj9873_file.ext'.
If a callable, it will be called with obj as input to get the key. One use case
If a callable, it will be called with obj as input to get the key. One use case
is to use a function that generates a key based on the object.
:param obj_arg_position_in_writer: Position of the object argument in writer function (0 or 1).
Expand Down Expand Up @@ -2015,6 +2015,12 @@ def written_key(
return key


# Often, a user might want to encode an object before writing it to a file.
# Therefore, they'll want to do a writer=Pipe(encoder, write_to_file), so we
# put write_to_file as an attribute of written_key to have it handy.
written_key.write_to_file = write_to_file


# TODO: This function should be symmetric, and if so, the code should use recursion
def invertible_maps(
mapping: Mapping = None, inv_mapping: Mapping = None
Expand Down

0 comments on commit 16158c0

Please sign in to comment.