Skip to content

Commit

Permalink
Switching the syntax 3.8 is happy with
Browse files Browse the repository at this point in the history
  • Loading branch information
WillJRoper committed May 27, 2024
1 parent eee6cc9 commit 455806a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/dir_wand/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from dir_wand.logger import Logger
from dir_wand.utils import swap_in_str

# Get the logger
logger = Logger()


class CommandRunner:
"""
Expand Down Expand Up @@ -75,7 +78,7 @@ def get_placeholders(self):
for match in matches:
self._placeholders.add(match)

@Logger().count("command")
@logger.count("command")
def run_command(self, **swaps):
"""
Run the command.
Expand Down
5 changes: 4 additions & 1 deletion src/dir_wand/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from dir_wand.logger import Logger
from dir_wand.utils import swap_in_str

# Get the logger
logger = Logger()


class Directory:
"""
Expand Down Expand Up @@ -153,7 +156,7 @@ def unpack_contents(self):
# Add the file to the files
self.files.append(f)

@Logger().count("directory")
@logger.count("directory")
def _make_dir_copy(self, path):
"""
Make a copy of the directory.
Expand Down
11 changes: 7 additions & 4 deletions src/dir_wand/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
from dir_wand.logger import Logger
from dir_wand.utils import swap_in_str

# Get the logger
logger = Logger()


class File:
"""
Expand Down Expand Up @@ -153,13 +156,13 @@ def get_placeholders(self):
for match in matches:
self._placeholders.add(match)

@Logger().count("file")
@logger.count("file")
def _make_softlink_copy(self, path):
"""Make a copy of a softlink."""
link = os.readlink(self.path)
os.symlink(link, path)

@Logger().count("file")
@logger.count("file")
def _make_executable_copy(self, path):
"""Make a copy of an executable file."""
# Copy the file
Expand All @@ -170,15 +173,15 @@ def _make_executable_copy(self, path):
# Copy the permissions
os.chmod(path, os.stat(path).st_mode)

@Logger().count("file")
@logger.count("file")
def _make_simple_copy(self, path):
"""Make a simple copy of a file."""
# Copy the file
with open(self.path, "rb") as file:
with open(path, "wb") as new_file:
new_file.write(file.read())

@Logger().count("file")
@logger.count("file")
def _make_copy_with_placeholders(self, path, **swaps):
"""
Make a copy of the file with the placeholders swapped out.
Expand Down

0 comments on commit 455806a

Please sign in to comment.