Skip to content

Commit 47a10c0

Browse files
Applied changes suggested in comment on issue #2
1 parent 9893077 commit 47a10c0

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/hermes_toml/harvest.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,10 @@ class TomlHarvestPlugin(HermesHarvestPlugin):
4242
def __call__(self, command: HermesHarvestCommand):
4343
"""start of the process of harvesting the .toml file"""
4444

45-
#set the working directory to the correct location
46-
path = command.args.path
47-
old_path = pathlib.Path.cwd()
48-
if path != old_path:
49-
chdir(path)
50-
51-
#harvesting the data from the .toml file specified in the Settings class
52-
data = self.read_from_toml(command.settings.toml.filename)
53-
54-
#resetting the working directory
55-
if path != old_path:
56-
chdir(old_path)
45+
#set the working directory temporary to the correct location
46+
with chdir(command.args.path):
47+
#harvesting the data from the .toml file specified in the Settings class
48+
data = self.read_from_toml(command.settings.toml.filename)
5749

5850
#returning the harvested data and some metadata
5951
return data, {"filename": command.settings.toml.filename}

0 commit comments

Comments
 (0)